1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! Active-staker set abstraction (ADR 022 §STORE Flow, §FIND\_VALUE Flow).
//!
//! The DHT handler consults the staker set on every `Store` admission
//! (reject records from non-staked publishers per ADR 022 §STORE Flow
//! line 140) and the requester-side iterative lookup consults it on
//! every response (ADR 022 §Lookup integrity step 2 — drop non-staked
//! `NodeId`s from `providers` and `closer_nodes`). This module owns the
//! trait + an in-memory implementation suitable for tests / the no-op
//! runtime default; the chain-backed `ChainStakerSet` lives next to it
//! in [`super::chain_staker_set`] and is wired by the runtime once the
//! alloy `Provider` is available.
use HashSet;
use crateNodeId;
/// 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.
/// In-memory [`StakerSet`] implementation, built from a parsed
/// `NodeId` set or empty.
///
/// The runtime wires the chain-backed `ChainStakerSet` (reads
/// `CapacityBond.getRegisteredNodes()` once at startup, then follows the registry's
/// membership events via the shared `eth_getLogs` poll) — see
/// `capacity_bond_registry::bootstrap`, #1110. This impl is what tests and
/// explicit operator-supplied sets use: construct via [`Self::new`] with a known
/// `HashSet`, or [`Self::empty`]. It implements the same `StakerSet` trait as
/// the chain-backed impl, so the two are interchangeable.