Skip to main content

Crate moloch_net

Crate moloch_net 

Source
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:

  1. Transport (transport.rs) - TCP connections with TLS, connection pooling
  2. Protocol (protocol.rs) - Message types and serialization
  3. Discovery (discovery.rs) - Peer discovery and scoring
  4. 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;

Modules§

discovery
Peer discovery for Moloch network.
protocol
Protocol messages for Moloch network communication.
sync
Chain synchronization protocol for Moloch.
transport
Transport layer for Moloch network.