-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Port the isValidatorForNextBlock utility from DTR branch.
Source
git show origin/dtr:src/libs/consensus/v2/routines/isValidator.ts
Target
src/libs/consensus/v2/routines/isValidator.ts
Code (26 lines - copy as-is)
import getShard from "./getShard"
import { Peer } from "@/libs/peer"
import { getSharedState } from "@/utilities/sharedState"
import getCommonValidatorSeed from "./getCommonValidatorSeed"
/**
* Determines whether the local node is included in the validator shard for the next block.
*/
export default async function isValidatorForNextBlock(): Promise<{
isValidator: boolean
validators: Peer[]
}> {
const { commonValidatorSeed } = await getCommonValidatorSeed()
const validators = await getShard(commonValidatorSeed)
return {
isValidator: validators.some(
peer => peer.identity === getSharedState.publicKeyHex,
),
validators,
}
}Notes
- This is fully transport-agnostic, no changes needed
- Uses existing getShard() and getCommonValidatorSeed()
[Beads: node-ge7]
coderabbitai
Metadata
Metadata
Assignees
Labels
No labels