Skip to main content

DhtConfig

Struct DhtConfig 

Source
pub struct DhtConfig {
Show 14 fields pub bind_addr: SocketAddr, pub bootstrap_nodes: Vec<String>, pub own_id: Option<Id20>, pub queries_per_second: usize, pub query_timeout: Duration, pub address_family: AddressFamily, pub enforce_node_id: bool, pub restrict_routing_ips: bool, pub dht_max_items: usize, pub dht_item_lifetime_secs: u64, pub max_routing_nodes: usize, pub state_dir: Option<PathBuf>, pub read_only_mode: bool, pub enable_multi_address: bool,
}
Expand description

Configuration for the DHT.

Fields§

§bind_addr: SocketAddr

Address to bind the UDP socket.

§bootstrap_nodes: Vec<String>

Bootstrap nodes (host:port strings resolved at startup).

§own_id: Option<Id20>

Our node ID. Generated randomly if None.

§queries_per_second: usize

Max outgoing queries per second (0 = unlimited).

§query_timeout: Duration

Timeout for individual KRPC queries.

§address_family: AddressFamily

Address family for this DHT instance (determines compact format and DNS filtering).

§enforce_node_id: bool

BEP 42: Enforce node ID verification when inserting into routing table. Nodes with IDs that don’t match their IP are rejected.

§restrict_routing_ips: bool

BEP 42: Restrict routing table to one node per IP address.

§dht_max_items: usize

BEP 44: Maximum number of stored DHT items (immutable + mutable).

§dht_item_lifetime_secs: u64

BEP 44: Lifetime of DHT items in seconds before expiry.

§max_routing_nodes: usize

Maximum number of nodes in the routing table. Prevents unbounded growth from adversarial node injection. Default: 512 (matches rqbit).

§state_dir: Option<PathBuf>

Directory for persisting DHT routing table state as JSON. When set, the actor saves/loads dht_state.json (V4) or dht_state_v6.json (V6) via atomic temp-file + rename.

§read_only_mode: bool

BEP 43: Read-only mode. When enabled, outgoing queries include ro: 1 and the node does not send announce_peer messages. Other nodes should not add us to their routing tables.

§enable_multi_address: bool

BEP 45: Include want in outgoing find_node/get_peers to request both IPv4 and IPv6 nodes from dual-stack peers.

Implementations§

Source§

impl DhtConfig

Source

pub fn default_v6() -> Self

Default configuration for an IPv6 DHT instance (BEP 24).

Trait Implementations§

Source§

impl Clone for DhtConfig

Source§

fn clone(&self) -> DhtConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DhtConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DhtConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more