network_config.rs

Overview

This file defines the NetworkConfig struct, which encapsulates the configuration settings for the network layer of a node within a distributed system. The network configuration includes addresses for various network sockets, TLS certificate paths, cryptographic key information, gossip protocol parameters, and API endpoint settings. The file provides default values, serialization/deserialization support through serde, and builder pattern construction via typed_builder.

The configuration parameters allow a node to establish secure and efficient communication with peers, proxies, and clients using QUIC over UDP, manage gossip protocol participation, and expose APIs for block management and general SDK interactions.

Detailed Description of Components

NetworkConfig Struct

The primary struct in this file, NetworkConfig, represents all necessary network-related settings for a node.

Properties

Methods

Default Value Functions

Several helper functions provide default values for fields in NetworkConfig to ensure sensible defaults and reduce configuration verbosity:

These functions are used as default value providers for serialization and builder defaulting.

Implementation Details and Algorithms

Interactions with Other System Components

Mermaid Diagram: Structure of NetworkConfig

classDiagram
class NetworkConfig {
+bind: SocketAddr
+my_cert: PathBuf
+my_key: PathBuf
+my_ed_key_secret: Vec<String>
+my_ed_key_path: Vec<String>
+subscribe: Vec<Vec<SocketAddr>>
+proxies: Vec<SocketAddr>
+peer_certs: Vec<PathBuf>
+peer_ed_pubkeys: Vec<VerifyingKey>
+node_advertise_addr: SocketAddr
+gossip_listen_addr: SocketAddr
+gossip_advertise_addr: Option<SocketAddr>
+gossip_seeds: Vec<SocketAddr>
+block_manager_listen_addr: SocketAddr
+static_storages: Vec<Url>
+api_addr: String
+api_advertise_addr: Url
+send_buffer_size: usize
+bm_api_socket: Option<SocketAddr>
+bk_api_socket: Option<SocketAddr>
+shared_state_max_download_tries: u8
+shared_state_retry_download_timeout_millis: u64
+chitchat_cluster_id: String
+max_nodes_with_same_id: u8
+get_gossip_seeds(): Vec<String>
}

This diagram visually represents the NetworkConfig struct including its fields and the single method get_gossip_seeds. The fields' types are abbreviated for clarity (SocketAddr, PathBuf, Vec, etc.). The diagram reflects that NetworkConfig is a data structure organizing network and protocol configuration parameters.