Expand description
Networking layer for Moloch audit chain.
This crate provides peer-to-peer communication for the Moloch chain:
- Transport layer with TLS 1.3
- Protocol messages for gossip and sync
- Peer discovery and management
- Chain synchronization protocols
§Architecture
The networking layer is organized into four main components:
- Transport (
transport.rs) - TCP connections with TLS, connection pooling - Protocol (
protocol.rs) - Message types and serialization - Discovery (
discovery.rs) - Peer discovery and scoring - Sync (
sync.rs) - Chain synchronization protocols
§Example
ⓘ
use moloch_net::{NetworkConfig, NetworkNode};
// Create node configuration
let config = NetworkConfig::builder()
.listen_addr("0.0.0.0:9000")
.chain_id("moloch-testnet")
.build();
// Start the network node
let node = NetworkNode::new(config, storage).await?;
node.connect_to_peers(&["peer1:9000", "peer2:9000"]).await?;Re-exports§
pub use discovery::PeerDiscovery;pub use discovery::PeerInfo;pub use discovery::PeerScore;pub use discovery::PeerState;pub use protocol::Message;pub use protocol::MessageCodec;pub use protocol::PeerId;pub use protocol::ProtocolVersion;pub use sync::SyncManager;pub use sync::SyncMode;pub use sync::SyncStatus;pub use transport::Connection;pub use transport::ConnectionPool;pub use transport::NetworkConfig;pub use transport::TlsConfig;pub use transport::Transport;pub use transport::TransportError;