pub struct NodeConfig {
pub bind_addr: Option<TransportAddr>,
pub known_peers: Vec<TransportAddr>,
pub keypair: Option<(MlDsaPublicKey, MlDsaSecretKey)>,
pub transport_providers: Vec<Arc<dyn TransportProvider>>,
pub data_channel_capacity: Option<usize>,
pub max_concurrent_uni_streams: Option<u32>,
pub max_message_size: Option<usize>,
pub port_mapping_enabled: Option<bool>,
}Expand description
Minimal configuration for P2P nodes
All fields are optional - the node will auto-configure everything.
bind_addr: Defaults to0.0.0.0:0(random port)known_peers: Defaults to empty (node can still accept connections)keypair: Defaults to fresh generated keypairtransport_providers: Defaults to UDP plus best-effort constrained transports such as BLE when available
§Example
// Zero configuration
let config = NodeConfig::default();
// Or with known peers
let config = NodeConfig::builder()
.known_peer("peer1.example.com:9000".parse()?)
.build();
// Or with additional transport providers
#[cfg(feature = "ble")]
let config = NodeConfig::builder()
.transport_provider(Arc::new(BleTransport::new().await?))
.build();Fields§
§bind_addr: Option<TransportAddr>Bind address. Default: 0.0.0.0:0 (random port)
known_peers: Vec<TransportAddr>Known peers for initial discovery. Default: empty When empty, node can still accept incoming connections.
keypair: Option<(MlDsaPublicKey, MlDsaSecretKey)>Identity keypair (ML-DSA-65). Default: fresh generated Provide for persistent identity across restarts.
transport_providers: Vec<Arc<dyn TransportProvider>>Additional transport providers beyond the default transport set.
UDP is always included, and constrained transports such as BLE are registered automatically when compiled in and available at runtime. Use this to add additional transports like LoRa, serial, etc.
Transport capabilities are propagated to peer advertisements and used for routing decisions.
data_channel_capacity: Option<usize>Data channel capacity (bounded mpsc between reader tasks and recv). Default: 256.
max_concurrent_uni_streams: Option<u32>Maximum concurrent unidirectional QUIC streams per connection. Default: 100.
max_message_size: Option<usize>Maximum bytes accepted for a single message read from a stream.
Default: crate::unified_config::P2pConfig::DEFAULT_MAX_MESSAGE_SIZE.
port_mapping_enabled: Option<bool>Reviewer P2 #2: surface ant-quic’s best-effort UPnP IGD port-mapping
toggle at the simpler NodeConfig builder layer (the existing knob
is only on P2pConfigBuilder). When Some(false), the UPnP
discovery + port-mapping task is skipped. When None, the ant-quic
default applies (currently enabled).
Implementations§
Source§impl NodeConfig
impl NodeConfig
Sourcepub fn builder() -> NodeConfigBuilder
pub fn builder() -> NodeConfigBuilder
Create a builder for fluent construction
Sourcepub fn with_bind_addr(addr: impl Into<TransportAddr>) -> Self
pub fn with_bind_addr(addr: impl Into<TransportAddr>) -> Self
Create config with a specific bind address
Sourcepub fn with_known_peers(
peers: impl IntoIterator<Item = impl Into<TransportAddr>>,
) -> Self
pub fn with_known_peers( peers: impl IntoIterator<Item = impl Into<TransportAddr>>, ) -> Self
Create config with known peers
Sourcepub fn with_keypair(
public_key: MlDsaPublicKey,
secret_key: MlDsaSecretKey,
) -> Self
pub fn with_keypair( public_key: MlDsaPublicKey, secret_key: MlDsaSecretKey, ) -> Self
Create config with a specific ML-DSA-65 keypair
Source§impl NodeConfig
impl NodeConfig
Sourcepub fn build_transport_registry(&self) -> TransportRegistry
pub fn build_transport_registry(&self) -> TransportRegistry
Build a transport registry from this configuration
Creates a registry containing all configured transport providers. If no providers are configured, returns an empty registry (UDP should be added by the caller based on bind_addr).
Sourcepub fn has_constrained_transports(&self) -> bool
pub fn has_constrained_transports(&self) -> bool
Check if this configuration has any non-UDP transport providers
Trait Implementations§
Source§impl Clone for NodeConfig
impl Clone for NodeConfig
Source§fn clone(&self) -> NodeConfig
fn clone(&self) -> NodeConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more