pub trait StakerSet:
Send
+ Sync
+ Debug {
// Required methods
fn is_active(&self, node_id: &NodeId) -> bool;
fn active_nodes(&self) -> Vec<NodeId>;
// Provided methods
fn len(&self) -> usize { ... }
fn is_empty(&self) -> bool { ... }
}Expand description
Read-only view of the cached active-staker set.
Implementations MUST be cheap to clone (typically Arc<inner>); the
handler holds a long-lived Arc<dyn StakerSet> and every admitted
Store / responded-FindValue request consults it on the hot path.
is_active is the only call the handler makes per request.
active_nodes is exposed for the bootstrap path (seed the routing
table from it) and for operator tooling.
There is deliberately no change-subscription seam. Consumers read the cached set directly; add a subscription only alongside the code that needs it.
Required Methods§
Sourcefn active_nodes(&self) -> Vec<NodeId>
fn active_nodes(&self) -> Vec<NodeId>
Snapshot of the active-staker set. Order is unspecified; the caller MUST randomize before any selection step that an attacker could influence (e.g. bootstrap target picking).
Provided Methods§
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Cardinality of the active set. Default implementation walks
Self::active_nodes; production impls (chain-backed cache, etc.)
SHOULD override with an O(1) counter.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".