Last active
October 29, 2024 10:54
-
-
Save ImmunefiEditor/323ccb166a47f3ac4e6463b23c510b14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function selectNodes(maxAllowed: number): void { | |
| const standbyNodesInfo = getStandbyNodesInfoMap() | |
| /* prettier-ignore */ if (logFlags.p2pNonFatal && logFlags.console) console.log('selecting from standbyNodesInfo', standbyNodesInfo) | |
| // construct a list of objects that we'll sort by `selectionNum`. we'll use | |
| // the public key to get the join request associated with the public key and | |
| // inform the node later that it has been accepted | |
| const objs: { | |
| publicKey: string | |
| selectionNum: string | |
| appJoinData?: Record<string, any> | null //appJoinData is required for golden ticket | |
| }[] = [] | |
| for (const [publicKey, info] of standbyNodesInfo) { | |
| objs.push({ | |
| publicKey, | |
| selectionNum: info.selectionNum, | |
| appJoinData: info.appJoinData, | |
| }) | |
| } | |
| /* snippet of code */ | |
| // If golden ticket is enabled, add nodes with adminCert + golden ticket to selectedPublicKeys if they are not already there | |
| if (shardus.config.p2p.goldenTicketEnabled === true) { | |
| for (const obj of objs) { | |
| if (obj.appJoinData?.adminCert?.goldenTicket === true && !selectedPublicKeys.has(obj.publicKey)) { // @audit no golden ticket verification | |
| /* prettier-ignore */ if (logFlags.p2pNonFatal && logFlags.console) console.log('selecting golden ticket nodes from standbyNodesInfo') | |
| selectedPublicKeys.add(obj.publicKey) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment