perf(disc): allow more FindNode failures (#1411)

This commit is contained in:
Matthias Seitz
2023-02-16 18:08:50 +01:00
committed by GitHub
parent 9b81b4f20d
commit 8a214d6f04
2 changed files with 4 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ pub struct Discv4Config {
pub udp_egress_message_buffer: usize,
/// Size of the channel buffer for incoming messages.
pub udp_ingress_message_buffer: usize,
/// The number of allowed failures for `FindNode` requests. Default: 1.
/// The number of allowed failures for `FindNode` requests. Default: 5.
pub max_find_node_failures: u8,
/// The interval to use when checking for expired nodes that need to be re-pinged. Default:
/// 300sec, 5min.
@@ -116,7 +116,7 @@ impl Default for Discv4Config {
udp_egress_message_buffer: 1024,
/// Every outgoing request will eventually lead to an incoming response
udp_ingress_message_buffer: 1024,
max_find_node_failures: 2,
max_find_node_failures: 5,
ping_interval: Duration::from_secs(300),
/// unified expiration and timeout durations, mirrors geth's `expiration` duration
ping_expiration: Duration::from_secs(20),

View File

@@ -1232,6 +1232,8 @@ impl Discv4Service {
self.pending_find_nodes.retain(|node_id, find_node_request| {
if now.duration_since(find_node_request.sent_at) > self.config.request_timeout {
if !find_node_request.answered {
// node actually responded but with fewer entries than expected, but we don't
// treat this as an hard error since it responded.
failed_neighbours.push(*node_id);
}
return false