1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Peer synchronization protocols and coordination.
//!
//! This module handles all aspects of state synchronization between nodes:
//! - Network protocols (libp2p streams, encryption)
//! - Sync strategy decisions (full vs delta)
//! - Peer state tracking
//! - Protocol implementations (full, delta, state)
//! - Ancillary protocols (key sharing, blob sharing)
//! - Metrics and observability
//!
//! ## Architecture (SOLID Principles Applied)
//!
//! ```text
//! SyncManager
//! ├── Orchestrates: periodic sync, peer selection
//! ├── Decides: Use delta or full resync
//! ├── Delegates to:
//! │ ├── hash_comparison_protocol.rs - Merkle tree traversal (DFS)
//! │ ├── level_sync.rs - Level-wise sync (BFS for wide trees)
//! │ ├── snapshot.rs - Snapshot transfer protocol
//! │ └── blobs.rs - Blob sharing
//! ├── Tracks: tracking.rs (per-peer sync history)
//! └── Observes: metrics.rs (protocol cost, safety invariants)
//! ```
//!
//! ## Metrics
//!
//! The sync module provides unified metrics through `SyncMetricsCollector`:
//! - Protocol cost: messages, bytes, round trips, entities, merges
//! - Phase timing: handshake, data_transfer, merge, sync_total
//! - Safety metrics: snapshot_blocked (I5), buffer_drops (I6), verification_failures (I7)
//!
//! See [`metrics`] module for trait definition and [`prometheus_metrics`] for production use.
pub
pub
pub use SyncConfig;
pub use ;
pub use ;
pub use SyncManager;
pub use ;
pub use PrometheusSyncMetrics;