Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 21 fields pub version: Version, pub enable_monitor: bool, pub handshake_timeout: u64, pub ping_interval: u64, pub ping_timeout: u64, pub max_connect_retries: usize, pub bootstrap_peers: Vec<Endpoint>, pub listen_endpoints: Vec<Endpoint>, pub discovery_endpoints: Vec<Endpoint>, pub peer_endpoints: Vec<Endpoint>, pub inbound_slots: usize, pub outbound_slots: usize, pub seeding_interval: u64, pub lookup_inbound_slots: usize, pub lookup_outbound_slots: usize, pub lookup_response_timeout: u64, pub lookup_connection_lifespan: u64, pub lookup_connect_retries: usize, pub refresh_interval: u64, pub refresh_response_timeout: u64, pub refresh_connect_retries: usize,
}
Expand description

Configuration for the p2p network.

peer_endpoints are static peers dialed directly (use for fixed topologies). bootstrap_peers are seeds for the default Kademlia discovery; the DHT grows the connection set from there. Custom Discovery implementations may interpret bootstrap_peers differently or ignore it. Pick one, or combine.

§Example

use karyon_p2p::Config;

let config = Config {
    listen_endpoints: vec![
        "tcp://0.0.0.0:8000".parse().unwrap(),
    ],
    discovery_endpoints: vec![
        "tcp://0.0.0.0:7000".parse().unwrap(),
        "udp://0.0.0.0:7000".parse().unwrap(),
    ],
    bootstrap_peers: vec![
        "tcp://seed.example.com:7000".parse().unwrap(),
    ],
    ..Config::default()
};

Fields§

§version: Version

Represents the network version.

§enable_monitor: bool

Enable monitor

§handshake_timeout: u64

Timeout duration for the handshake with new peers, in seconds.

§ping_interval: u64

Interval at which the ping protocol sends ping messages to a peer to maintain connections, in seconds.

§ping_timeout: u64

Timeout duration for receiving the pong message corresponding to the sent ping message, in seconds.

§max_connect_retries: usize

The maximum number of retries for outbound connection establishment.

§bootstrap_peers: Vec<Endpoint>

A list of bootstrap peers for the seeding process.

§listen_endpoints: Vec<Endpoint>

Endpoints to listen on for incoming peer connections. e.g. [tcp://0.0.0.0:8000, quic://0.0.0.0:9000]

§discovery_endpoints: Vec<Endpoint>

Endpoints used by the discovery service (Kademlia by default).

Kademlia needs two sockets that serve different roles:

  • one stream endpoint for the lookup service (tcp://, tls://, or quic:// when the quic feature is on). Handles short-lived FIND_NODE / Ping queries from other peers.
  • one udp:// endpoint for the refresh service. Handles UDP liveness pings against routing-table entries.

Either provide both (one of each kind) or leave the vector empty to disable Kademlia-style DHT discovery and rely on peer_endpoints + bootstrap_peers for static peering.

e.g. [tcp://0.0.0.0:7000, udp://0.0.0.0:7000]

§peer_endpoints: Vec<Endpoint>

A list of endpoints representing peers that the Discovery will manually connect to.

§inbound_slots: usize

The number of available inbound slots for incoming connections.

§outbound_slots: usize

The number of available outbound slots for outgoing connections.

§seeding_interval: u64

Time interval, in seconds, at which the Discovery restarts the seeding process.

§lookup_inbound_slots: usize

The number of available inbound slots for incoming connections during the lookup process.

§lookup_outbound_slots: usize

The number of available outbound slots for outgoing connections during the lookup process.

§lookup_response_timeout: u64

Timeout duration for a peer response during the lookup process, in seconds.

§lookup_connection_lifespan: u64

Maximum allowable time for a live connection with a peer during the lookup process, in seconds.

§lookup_connect_retries: usize

The maximum number of retries for outbound connection establishment during the lookup process.

§refresh_interval: u64

Interval at which the table refreshes its entries, in seconds.

§refresh_response_timeout: u64

Timeout duration for a peer response during the table refresh process, in seconds.

§refresh_connect_retries: usize

The maximum number of retries for outbound connection establishment during the refresh process.

Trait Implementations§

Source§

impl Default for Config

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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, 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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