pub fn select_protocol(
local: &SyncHandshake,
remote: &SyncHandshake,
) -> ProtocolSelectionExpand description
Select the optimal sync protocol based on handshake information.
Implements the decision table from CIP ยง2.3:
| # | Condition | Selected Protocol |
|---|---|---|
| 1 | root_hash match | None |
| 2 | !has_state (fresh node) | Snapshot |
| 3 | has_state AND divergence >50% | HashComparison |
| 4 | max_depth >3 AND divergence <20% | SubtreePrefetch |
| 5 | entity_count >50 AND divergence <10% | BloomFilter |
| 6 | max_depth 1-2 AND avg children/level >10 | LevelWise |
| 7 | (default) | HashComparison |
CRITICAL (Invariant I5): Snapshot is NEVER selected for initialized nodes. This prevents silent data loss from overwriting local CRDT state.