pub struct NodeConfig {Show 16 fields
pub local: bool,
pub port: u16,
pub ipv6: bool,
pub bootstrap_peers: Vec<MultiAddr>,
pub connection_timeout: Duration,
pub max_connections: usize,
pub dht_config: DHTConfig,
pub bootstrap_cache_config: Option<BootstrapConfig>,
pub diversity_config: Option<IPDiversityConfig>,
pub max_message_size: Option<usize>,
pub node_identity: Option<Arc<NodeIdentity>>,
pub mode: NodeMode,
pub custom_user_agent: Option<String>,
pub allow_loopback: bool,
pub adaptive_dht_config: AdaptiveDhtConfig,
pub close_group_cache_dir: Option<PathBuf>,
}Expand description
Configuration for a P2P node
Fields§
§local: boolBind to loopback only (127.0.0.1 / ::1).
When true, the node listens on loopback addresses suitable for
local development and testing. When false (the default), the node
listens on all interfaces (0.0.0.0 / ::).
port: u16Listen port. 0 means OS-assigned ephemeral port.
ipv6: boolEnable IPv6 dual-stack binding.
When true (the default), both an IPv4 and an IPv6 address are
bound. When false, only IPv4 is used.
bootstrap_peers: Vec<MultiAddr>Bootstrap peers to connect to on startup.
connection_timeout: DurationConnection timeout duration
max_connections: usizeMaximum number of concurrent connections
dht_config: DHTConfigDHT configuration
bootstrap_cache_config: Option<BootstrapConfig>Bootstrap cache configuration
diversity_config: Option<IPDiversityConfig>Optional IP diversity configuration for Sybil protection tuning.
When set, this configuration is used by bootstrap peer discovery and
other diversity-enforcing subsystems. If None, defaults are used.
max_message_size: Option<usize>Optional override for the maximum application-layer message size.
When None, the underlying saorsa-transport default is used.
node_identity: Option<Arc<NodeIdentity>>Optional node identity for app-level message signing.
When set, outgoing messages are signed with the node’s ML-DSA-65 key and incoming signed messages are verified at the transport layer.
mode: NodeModeOperating mode of this node.
Determines the default user agent and DHT participation:
Node→ user agent"node/<version>", added to DHT routing tables.Client→ user agent"client/<version>", treated as ephemeral.
custom_user_agent: Option<String>Optional custom user agent override.
When Some, this value is used instead of the mode-derived default.
When None, the user agent is derived from NodeConfig::mode.
allow_loopback: boolAllow loopback addresses (127.0.0.1, ::1) in the transport layer.
In production, loopback addresses are rejected because they are not routable. Enable this for local devnets and testnets where all nodes run on the same machine.
Default: false
adaptive_dht_config: AdaptiveDhtConfigAdaptive DHT configuration (trust-based swap-out).
Controls whether peers with low trust scores are eligible for
swap-out from the routing table when better candidates arrive. Use
NodeConfigBuilder::trust_enforcement for a simple on/off toggle.
Default: enabled with a swap threshold of 0.35.
close_group_cache_dir: Option<PathBuf>Optional path for persisting the close group cache.
Directory for persisting the close group cache.
When set, the node saves its close group peers and their trust
scores to {dir}/close_group_cache.json on shutdown and after
bootstrap. On startup, cached peers are loaded and contacted
first, preserving close group consistency across restarts.
When None, no close group cache is used.
Implementations§
Source§impl NodeConfig
impl NodeConfig
Sourcepub fn user_agent(&self) -> String
pub fn user_agent(&self) -> String
Returns the effective user agent string.
If a custom user agent was set, returns that. Otherwise, derives
the user agent from the node’s NodeMode.
Sourcepub fn listen_addrs(&self) -> Vec<MultiAddr>
pub fn listen_addrs(&self) -> Vec<MultiAddr>
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