Expand description
Shared sync state abstractions for protocol negotiation.
Provides types and functions shared between production code (SyncManager)
and simulation (SimNode) for building handshakes and protocol selection.
§Design
LocalSyncStatetrait abstracts access to node statebuild_handshake()creates handshakes from any implementor- Estimation functions provide consistent heuristics for both environments
§Usage
ⓘ
// Any type can provide its local state
impl LocalSyncState for MyNode {
fn root_hash(&self) -> [u8; 32] { ... }
fn entity_count(&self) -> u64 { ... }
fn max_depth(&self) -> u32 { ... }
fn dag_heads(&self) -> Vec<[u8; 32]> { ... }
}
// Build handshake using shared logic
let handshake = build_handshake(&my_node);
// Use select_protocol() for negotiation
let selection = select_protocol(&local_hs, &remote_hs);Traits§
- Local
Sync State - Trait for accessing local sync state.
Functions§
- build_
handshake - Build a
SyncHandshakefrom any type implementingLocalSyncState. - build_
handshake_ from_ raw - Build a
SyncHandshakefrom raw state values. - estimate_
entity_ count - Estimate entity count from available data.
- estimate_
max_ depth - Estimate max depth from entity count.