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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! # ethrex P2P Networking
//!
//! Peer-to-peer networking layer for the ethrex Ethereum client.
//!
//! ## Overview
//!
//! This crate implements the Ethereum P2P networking stack:
//! - **Discovery**: Node discovery using discv4 (and experimental discv5)
//! - **RLPx**: Encrypted transport protocol for peer communication
//! - **eth Protocol**: Block and transaction propagation
//! - **snap Protocol**: Fast state synchronization
//!
//! ## Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ Network Layer │
//! │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
//! │ │ discv4 │ │ RLPx │ │ Peer Handler │ │
//! │ │ (Discovery) │ │ (Transport) │ │ (Messages) │ │
//! │ └─────────────┘ └─────────────┘ └─────────────────────┘ │
//! └─────────────────────────────────────────────────────────────┘
//! │
//! ┌──────────────────┼──────────────────┐
//! ▼ ▼ ▼
//! ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
//! │ Sync Manager │ │ TX Broadcaster │ │ Snap Sync │
//! └─────────────────┘ └─────────────────┘ └─────────────────┘
//! ```
//!
//! ## Key Components
//!
//! - [`network`]: Network initialization and peer management
//! - [`peer_handler`]: Message handling for connected peers
//! - [`sync_manager`]: Block synchronization coordination
//! - [`sync`]: Full and snap sync implementations
//! - [`tx_broadcaster`]: Transaction pool broadcasting
//! - [`discv4`]: Node discovery protocol v4
//! - [`rlpx`]: RLPx encrypted transport
//!
//! ## Usage
//!
//! ```ignore
//! use ethrex_p2p::{start_network, SyncManager};
//!
//! // Start the P2P network
//! let (sync_manager, peer_handler) = start_network(
//! udp_addr,
//! tcp_addr,
//! bootnodes,
//! signer,
//! storage,
//! blockchain,
//! ).await?;
//!
//! // Start synchronization
//! sync_manager.start_sync().await?;
//! ```
//!
//! ## Protocols
//!
//! - **eth/68**: Block and transaction exchange
//! - **snap/1**: State snapshot synchronization
//!
pub
pub use DiscoveryConfig;
pub use periodically_show_peer_stats;
pub use start_network;