Skip to main content

StakerSet

Trait StakerSet 

Source
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§

Source

fn is_active(&self, node_id: &NodeId) -> bool

Whether node_id is in the active-staker set.

Source

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§

Source

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.

Source

fn is_empty(&self) -> bool

Convenience over Self::len.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§