pub struct CoreNodeConfig {Show 15 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,
}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 blocking and eviction).
Controls whether peers with low trust scores are evicted from the
routing table and blocked from DHT operations. Use
[NodeConfigBuilder::trust_enforcement] for a simple on/off toggle.
Default: enabled with a block threshold of 0.15.
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>
Sourcepub fn new() -> Result<NodeConfig, P2PError>
pub fn new() -> Result<NodeConfig, P2PError>
Create a new NodeConfig with default values
§Errors
Returns an error if default addresses cannot be parsed
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 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
Source§impl<'de> Deserialize<'de> for NodeConfig
impl<'de> Deserialize<'de> for NodeConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<NodeConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<NodeConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for NodeConfig
impl Serialize for NodeConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for NodeConfig
impl RefUnwindSafe for NodeConfig
impl Send for NodeConfig
impl Sync for NodeConfig
impl Unpin for NodeConfig
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more