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?;