Struct discv5::ConfigBuilder
source · pub struct ConfigBuilder { /* private fields */ }
Implementations§
source§impl ConfigBuilder
impl ConfigBuilder
pub fn new(listen_config: ListenConfig) -> Self
sourcepub fn enable_packet_filter(&mut self) -> &mut Self
pub fn enable_packet_filter(&mut self) -> &mut Self
Whether to enable the incoming packet filter.
sourcepub fn request_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn request_timeout(&mut self, timeout: Duration) -> &mut Self
The request timeout for each UDP request.
sourcepub fn vote_duration(&mut self, vote_duration: Duration) -> &mut Self
pub fn vote_duration(&mut self, vote_duration: Duration) -> &mut Self
The interval over which votes are remembered when determining our external IP. A lower interval will respond faster to IP changes. Default is 30 seconds.
sourcepub fn query_peer_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn query_peer_timeout(&mut self, timeout: Duration) -> &mut Self
The timeout after which a QueryPeer
in an ongoing query is marked unresponsive.
Unresponsive peers don’t count towards the parallelism limits for a query.
Hence, we may potentially end up making more requests to good peers.
sourcepub fn query_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn query_timeout(&mut self, timeout: Duration) -> &mut Self
The timeout for an entire query. Any peers discovered before this timeout are returned.
sourcepub fn request_retries(&mut self, retries: u8) -> &mut Self
pub fn request_retries(&mut self, retries: u8) -> &mut Self
The number of retries for each UDP request.
sourcepub fn session_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn session_timeout(&mut self, timeout: Duration) -> &mut Self
The session timeout for each node.
sourcepub fn session_cache_capacity(&mut self, capacity: usize) -> &mut Self
pub fn session_cache_capacity(&mut self, capacity: usize) -> &mut Self
The maximum number of established sessions to maintain.
sourcepub fn disable_enr_update(&mut self) -> &mut Self
pub fn disable_enr_update(&mut self) -> &mut Self
Disables the auto-update of the local ENR IP and port based on PONG responses from peers.
sourcepub fn max_nodes_response(&mut self, max: usize) -> &mut Self
pub fn max_nodes_response(&mut self, max: usize) -> &mut Self
The maximum number of nodes we response to a find nodes request.
sourcepub fn enr_peer_update_min(&mut self, min: usize) -> &mut Self
pub fn enr_peer_update_min(&mut self, min: usize) -> &mut Self
The minimum number of peer’s who agree on an external IP port before updating the local ENR.
sourcepub fn query_parallelism(&mut self, parallelism: usize) -> &mut Self
pub fn query_parallelism(&mut self, parallelism: usize) -> &mut Self
The number of peers to request in parallel in a single query.
sourcepub fn ip_limit(&mut self) -> &mut Self
pub fn ip_limit(&mut self) -> &mut Self
Limits the number of IP addresses from the same /24 subnet in the kbuckets table. This is to mitigate eclipse attacks.
sourcepub fn incoming_bucket_limit(&mut self, limit: usize) -> &mut Self
pub fn incoming_bucket_limit(&mut self, limit: usize) -> &mut Self
Sets a maximum limit to the number of incoming nodes (nodes that have dialed us) to exist per-bucket. This cannot be larger than the bucket size (16). By default, half of every bucket (8 positions) is the largest number of nodes that we accept that dial us.
sourcepub fn table_filter(&mut self, filter: fn(_: &Enr) -> bool) -> &mut Self
pub fn table_filter(&mut self, filter: fn(_: &Enr) -> bool) -> &mut Self
A filter used to decide whether to insert nodes into our local routing table. Nodes can be excluded if they do not pass this filter.
sourcepub fn ping_interval(&mut self, interval: Duration) -> &mut Self
pub fn ping_interval(&mut self, interval: Duration) -> &mut Self
The time between pings to ensure connectivity amongst connected nodes.
sourcepub fn disable_report_discovered_peers(&mut self) -> &mut Self
pub fn disable_report_discovered_peers(&mut self) -> &mut Self
Disables reporting of discovered peers through the event stream.
sourcepub fn filter_rate_limiter(
&mut self,
rate_limiter: Option<RateLimiter>
) -> &mut Self
pub fn filter_rate_limiter( &mut self, rate_limiter: Option<RateLimiter> ) -> &mut Self
A rate limiter for limiting inbound requests.
sourcepub fn filter_max_nodes_per_ip(
&mut self,
max_nodes_per_ip: Option<usize>
) -> &mut Self
pub fn filter_max_nodes_per_ip( &mut self, max_nodes_per_ip: Option<usize> ) -> &mut Self
If the filter is enabled, sets the maximum number of nodes per IP before banning the IP.
sourcepub fn filter_max_bans_per_ip(
&mut self,
max_bans_per_ip: Option<usize>
) -> &mut Self
pub fn filter_max_bans_per_ip( &mut self, max_bans_per_ip: Option<usize> ) -> &mut Self
The maximum number of times nodes from a single IP can be banned, before the IP itself gets banned.
sourcepub fn permit_ban_list(&mut self, list: PermitBanList) -> &mut Self
pub fn permit_ban_list(&mut self, list: PermitBanList) -> &mut Self
A set of lists that permit or ban IP’s or NodeIds from the server. See
crate::PermitBanList
.
sourcepub fn ban_duration(&mut self, ban_duration: Option<Duration>) -> &mut Self
pub fn ban_duration(&mut self, ban_duration: Option<Duration>) -> &mut Self
Set the default duration for which nodes are banned for. This timeouts are checked every 5 minutes,
so the precision will be to the nearest 5 minutes. If set to None
, bans from the filter
will last indefinitely. Default is 1 hour.
sourcepub fn executor(
&mut self,
executor: Box<dyn Executor + Send + Sync>
) -> &mut Self
pub fn executor( &mut self, executor: Box<dyn Executor + Send + Sync> ) -> &mut Self
A custom executor which can spawn the discv5 tasks. This must be a tokio runtime, with timing support.