pub struct NetworkConfig {Show 26 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 disable_block_relay_only_connection: bool,
pub channel_size: Option<usize>,
pub trusted_proxies: Vec<IpAddr>,
pub sync: SyncConfig,
pub proxy: ProxyConfig,
pub onion: OnionConfig,
}Expand description
Network config options.
Fields§
§whitelist_only: boolOnly connect to whitelist peers.
max_peers: u32Maximum number of allowed connected peers.
The node will evict connections when the number exceeds this limit.
max_outbound_peers: u32Maximum number of outbound peers.
When node A connects to B, B is the outbound peer of A.
path: PathBufNetwork data storage directory path.
dns_seeds: Vec<String>A list of DNS servers to discover peers.
discovery_local_address: boolWhether to probe and store local addresses.
discovery_announce_check_interval_secs: Option<u64>The interval between discovery announce message checking.
ping_interval_secs: u64Interval between pings in seconds.
A node pings peer regularly to see whether the connection is alive.
ping_timeout_secs: u64The ping timeout in seconds.
If a peer does not respond to ping before the timeout, it is evicted.
connect_outbound_interval_secs: u64The 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: boolEnable UPNP when the router supports it.
bootnode_mode: boolEnable 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: boolNetwork use reuse port or not
reuse_tcp_with_ws: boolAllow ckb to upgrade tcp listening to tcp + ws listening
disable_block_relay_only_connection: boolDisable block_relay_only connection, only use for testing.
channel_size: Option<usize>Tentacle inner channel_size.
trusted_proxies: Vec<IpAddr>A list of trusted proxies’ IP addresses.
sync: SyncConfigChain synchronization config options.
proxy: ProxyConfigProxy related config options
onion: OnionConfigOnion related config options
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 onion_private_key_path(&self) -> PathBuf
pub fn onion_private_key_path(&self) -> PathBuf
Gets the onion network private 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 UnsafeUnpin 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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