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>>,
}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 transport only
§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 UDP transport.
The UDP transport is always included by default. Use this to add additional transports like BLE, LoRa, serial, etc.
Transport capabilities are propagated to peer advertisements and used for routing decisions.
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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more