config.rs

Overview

The config.rs file defines the NetworkConfig struct, which encapsulates the network configuration parameters necessary for establishing and managing network communication within the system. This includes binding addresses, security credentials, subscription peers, and proxy nodes. The file also provides the construction logic for NetworkConfig, integrating certificate handling and cryptographic keys to facilitate secure network communication.

Detailed Description

Struct: NetworkConfig

The NetworkConfig struct holds the core configuration for the network layer:

Methods

NetworkConfig::new

pub fn new(
    bind: SocketAddr,
    my_cert: CertFile,
    my_key: PrivateKeyFile,
    my_ed_keys: &[transport_layer::SigningKey],
    trusted_certs: CertStore,
    trusted_pubkeys: HashSet<transport_layer::VerifyingKey>,
    subscribe: Vec<Vec<SocketAddr>>,
    proxies: Vec<SocketAddr>,
    tls_cert_cache: Option<TlsCertCache>,
) -> anyhow::Result<Self>

Important Implementation Details

Interactions with Other System Components

Diagram: Structure of config.rs

classDiagram
class NetworkConfig {
+bind: SocketAddr
+credential: NetCredential
+subscribe: Vec<Vec<SocketAddr>>
+proxies: Vec<SocketAddr>
+new()
}
NetworkConfig ..> NetCredential : uses
NetworkConfig ..> CertFile : uses
NetworkConfig ..> PrivateKeyFile : uses
NetworkConfig ..> CertStore : uses
NetworkConfig ..> TlsCertCache : optional
NetworkConfig ..> transport_layer::SigningKey : uses
NetworkConfig ..> transport_layer::VerifyingKey : uses

This diagram shows the core NetworkConfig struct and its dependencies on certificate, key, and transport layer types. The new method orchestrates the creation and assembly of these components into a network configuration instance.