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
impl Config
Sourcepub fn secret_key_path(&self) -> PathBuf
pub fn secret_key_path(&self) -> PathBuf
Gets the network secret key path.
Sourcepub fn peer_store_path(&self) -> PathBuf
pub fn peer_store_path(&self) -> PathBuf
Gets the peer store path.
Sourcepub fn create_dir_if_not_exists(&self) -> Result<(), Error>
pub fn create_dir_if_not_exists(&self) -> Result<(), Error>
Creates missing directories.
Sourcepub fn max_inbound_peers(&self) -> u32
pub fn max_inbound_peers(&self) -> u32
Gets maximum inbound peers.
Sourcepub fn max_outbound_peers(&self) -> u32
pub fn max_outbound_peers(&self) -> u32
Gets maximum outbound peers.
Sourcepub fn max_send_buffer(&self) -> usize
pub fn max_send_buffer(&self) -> usize
Gets maximum send buffer size.
Sourcepub fn channel_size(&self) -> usize
pub fn channel_size(&self) -> usize
Gets maximum send buffer size.
Sourcepub fn fetch_private_key(&self) -> Result<SecioKeyPair, Error>
pub fn fetch_private_key(&self) -> Result<SecioKeyPair, Error>
Reads the private key from file or generates one if the file does not exist.
Sourcepub fn whitelist_peers(&self) -> Vec<Multiaddr>
pub fn whitelist_peers(&self) -> Vec<Multiaddr>
Gets the list of whitelist peers.
Sourcepub fn outbound_peer_service_enabled(&self) -> bool
pub fn outbound_peer_service_enabled(&self) -> bool
Checks whether the outbound peer service should be enabled.
Sourcepub fn dns_seeding_service_enabled(&self) -> bool
pub fn dns_seeding_service_enabled(&self) -> bool
Checks whether the DNS seeding service should be enabled.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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> 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> 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