@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
26 lines • 1.12 kB
JavaScript
import { MapDef } from "@lodestar/utils";
/**
* Tracks signed proposer preferences we've already seen per (dependent_root, proposal_slot, validator_index).
*/
export class SeenProposerPreferences {
validatorByDependentRootBySlot = new MapDef(() => new Map());
isKnown(dependentRoot, proposalSlot, validatorIndex) {
return this.validatorByDependentRootBySlot.get(proposalSlot)?.get(dependentRoot) === validatorIndex;
}
add(dependentRoot, proposalSlot, validatorIndex) {
this.validatorByDependentRootBySlot.getOrDefault(proposalSlot).set(dependentRoot, validatorIndex);
}
/**
* Entries are only load-bearing while `proposal_slot > current_slot`. Once the slot has
* passed the `[IGNORE] proposal_slot > current_slot` gossip rule takes over, so drop them
* on each slot tick.
*/
prune(currentSlot) {
for (const slot of this.validatorByDependentRootBySlot.keys()) {
if (slot < currentSlot) {
this.validatorByDependentRootBySlot.delete(slot);
}
}
}
}
//# sourceMappingURL=seenProposerPreferences.js.map