ckb_app_config

Struct NetworkConfig

Source
pub struct NetworkConfig {
Show 22 fields pub whitelist_only: bool, pub max_peers: u32, pub max_outbound_peers: u32, pub path: PathBuf, pub dns_seeds: Vec<String>, pub discovery_local_address: bool, pub discovery_announce_check_interval_secs: Option<u64>, pub ping_interval_secs: u64, pub ping_timeout_secs: u64, pub connect_outbound_interval_secs: u64, pub listen_addresses: Vec<Multiaddr>, pub public_addresses: Vec<Multiaddr>, pub bootnodes: Vec<Multiaddr>, pub whitelist_peers: Vec<Multiaddr>, pub upnp: bool, pub bootnode_mode: bool, pub support_protocols: Vec<SupportProtocol>, pub max_send_buffer: Option<usize>, pub reuse_port_on_linux: bool, pub reuse_tcp_with_ws: bool, pub sync: SyncConfig, pub channel_size: Option<usize>,
}
Expand description

Network config options.

Fields§

§whitelist_only: bool

Only connect to whitelist peers.

§max_peers: u32

Maximum number of allowed connected peers.

The node will evict connections when the number exceeds this limit.

§max_outbound_peers: u32

Maximum number of outbound peers.

When node A connects to B, B is the outbound peer of A.

§path: PathBuf

Network data storage directory path.

§dns_seeds: Vec<String>

A list of DNS servers to discover peers.

§discovery_local_address: bool

Whether to probe and store local addresses.

§discovery_announce_check_interval_secs: Option<u64>

The interval between discovery announce message checking.

§ping_interval_secs: u64

Interval between pings in seconds.

A node pings peer regularly to see whether the connection is alive.

§ping_timeout_secs: u64

The ping timeout in seconds.

If a peer does not respond to ping before the timeout, it is evicted.

§connect_outbound_interval_secs: u64

The interval between trials to connect more outbound peers.

§listen_addresses: Vec<Multiaddr>

Listen addresses.

§public_addresses: Vec<Multiaddr>

Public addresses.

Set this if this is different from listen_addresses.

§bootnodes: Vec<Multiaddr>

A list of peers used to boot the node discovery.

Bootnodes are used to bootstrap the discovery when local peer storage is empty.

§whitelist_peers: Vec<Multiaddr>

A list of peers added in the whitelist.

When whitelist_only is enabled, the node will only connect to peers in this list.

§upnp: bool

Enable UPNP when the router supports it.

§bootnode_mode: bool

Enable bootnode mode.

It is recommended to enable this when this server is intended to be used as a node in the bootnodes.

§support_protocols: Vec<SupportProtocol>

Supported protocols list

§max_send_buffer: Option<usize>

Max send buffer size in bytes.

§reuse_port_on_linux: bool

Network use reuse port or not

§reuse_tcp_with_ws: bool

Allow ckb to upgrade tcp listening to tcp + ws listening

§sync: SyncConfig

Chain synchronization config options.

§channel_size: Option<usize>

Tentacle inner channel_size.

Implementations§

Source§

impl Config

Source

pub fn secret_key_path(&self) -> PathBuf

Gets the network secret key path.

Source

pub fn peer_store_path(&self) -> PathBuf

Gets the peer store path.

Source

pub fn create_dir_if_not_exists(&self) -> Result<(), Error>

Creates missing directories.

Source

pub fn max_inbound_peers(&self) -> u32

Gets maximum inbound peers.

Source

pub fn max_outbound_peers(&self) -> u32

Gets maximum outbound peers.

Source

pub fn max_send_buffer(&self) -> usize

Gets maximum send buffer size.

Source

pub fn channel_size(&self) -> usize

Gets maximum send buffer size.

Source

pub fn fetch_private_key(&self) -> Result<SecioKeyPair, Error>

Reads the private key from file or generates one if the file does not exist.

Source

pub fn whitelist_peers(&self) -> Vec<Multiaddr>

Gets the list of whitelist peers.

Source

pub fn bootnodes(&self) -> Vec<Multiaddr>

Gets a list of bootnodes.

Source

pub fn outbound_peer_service_enabled(&self) -> bool

Checks whether the outbound peer service should be enabled.

Source

pub fn dns_seeding_service_enabled(&self) -> bool

Checks whether the DNS seeding service should be enabled.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Config

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

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Cast to trait Any
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, dst: *mut u8)

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

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T