Skip to main content

LocalSyncState

Trait LocalSyncState 

Source
pub trait LocalSyncState {
    // Required methods
    fn root_hash(&self) -> [u8; 32];
    fn entity_count(&self) -> u64;
    fn max_depth(&self) -> u32;
    fn dag_heads(&self) -> Vec<[u8; 32]>;

    // Provided method
    fn has_state(&self) -> bool { ... }
}
Expand description

Trait for accessing local sync state.

Implement this trait to enable building handshakes and protocol selection. Both SyncManager (production) and SimNode (simulation) implement this, ensuring consistent behavior across both environments.

Required Methods§

Source

fn root_hash(&self) -> [u8; 32]

Current Merkle root hash.

Returns [0; 32] for fresh nodes with no state.

Source

fn entity_count(&self) -> u64

Number of entities in local storage.

Used for divergence calculation in protocol selection.

Source

fn max_depth(&self) -> u32

Maximum depth of the Merkle tree.

Used to select optimal sync protocol:

  • Depth > 3 with low divergence → SubtreePrefetch
  • Depth 1-2 with many children → LevelWise
Source

fn dag_heads(&self) -> Vec<[u8; 32]>

Current DAG heads (latest delta IDs).

Used for delta sync compatibility checking.

Provided Methods§

Source

fn has_state(&self) -> bool

Whether this node has any state.

Default implementation: root_hash != [0; 32]

Implementors§