pub struct NodeConfig {
pub bind_addr: Option<SocketAddr>,
pub known_peers: Vec<SocketAddr>,
pub keypair: Option<(MlDsaPublicKey, MlDsaSecretKey)>,
}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 keypair
§Example
ⓘ
// Zero configuration
let config = NodeConfig::default();
// Or with known peers
let config = NodeConfig::builder()
.known_peer("peer1.example.com:9000".parse()?)
.build();Fields§
§bind_addr: Option<SocketAddr>Bind address. Default: 0.0.0.0:0 (random port)
known_peers: Vec<SocketAddr>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.
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: SocketAddr) -> Self
pub fn with_bind_addr(addr: SocketAddr) -> Self
Create config with a specific bind address
Sourcepub fn with_known_peers(peers: Vec<SocketAddr>) -> Self
pub fn with_known_peers(peers: Vec<SocketAddr>) -> 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
Trait Implementations§
Source§impl Clone for NodeConfig
impl Clone for NodeConfig
Source§fn clone(&self) -> NodeConfig
fn clone(&self) -> NodeConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NodeConfig
impl Debug for NodeConfig
Source§impl Default for NodeConfig
impl Default for NodeConfig
Source§fn default() -> NodeConfig
fn default() -> NodeConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for NodeConfig
impl RefUnwindSafe for NodeConfig
impl Send for NodeConfig
impl Sync for NodeConfig
impl Unpin for NodeConfig
impl UnwindSafe for NodeConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more