Skip to content

Commit

Permalink
use previous cycle marker to calculate cert scores (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmxdiqbal authored Jan 20, 2025
1 parent fbcf49a commit 1ec9f43
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/p2p/CycleCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,12 @@ function scoreCert(cert: P2P.CycleCreatorTypes.CycleCert): number {
const id = NodeList.byPubKey.get(cert.sign.owner).id // get node id from cert pub key
const obj = { id }
const hid = crypto.hash(obj) // Omar - use hash of id so the cert is not made by nodes that are near based on node id
const out = utils.XOR(cert.marker, hid)

// since we dont have the prev cycle marker stored in the cycle record, we need to hash it each time. Alternatively, we
// can just use CycleChain.newest.previous, which is the cycle marker of the cycle two cycles before the current one
// I am partial to this, but I have done the previous cycle marker for now since that is what the ticket asked for
const prevMarker = makeCycleMarker(CycleChain.newest)
const out = utils.XOR(prevMarker, hid)
return out
} catch (err) {
error('scoreCert ERR:', err)
Expand Down

0 comments on commit 1ec9f43

Please sign in to comment.