Skip to main content

Module state_machine

Module state_machine 

Source
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

  • LocalSyncState trait abstracts access to node state
  • build_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§

LocalSyncState
Trait for accessing local sync state.

Functions§

build_handshake
Build a SyncHandshake from any type implementing LocalSyncState.
build_handshake_from_raw
Build a SyncHandshake from raw state values.
estimate_entity_count
Estimate entity count from available data.
estimate_max_depth
Estimate max depth from entity count.