Skip to main content

select_protocol

Function select_protocol 

Source
pub fn select_protocol(
    local: &SyncHandshake,
    remote: &SyncHandshake,
) -> ProtocolSelection
Expand description

Select the optimal sync protocol based on handshake information.

Implements the decision table from CIP ยง2.3:

#ConditionSelected Protocol
1root_hash matchNone
2!has_state (fresh node)Snapshot
3has_state AND divergence >50%HashComparison
4max_depth >3 AND divergence <20%SubtreePrefetch
5entity_count >50 AND divergence <10%BloomFilter
6max_depth 1-2 AND avg children/level >10LevelWise
7(default)HashComparison

CRITICAL (Invariant I5): Snapshot is NEVER selected for initialized nodes. This prevents silent data loss from overwriting local CRDT state.