Skip to content

Commit

Permalink
More lenient ipv6 auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
AgeManning committed Oct 8, 2024
1 parent 994a61b commit b8b1eaf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,28 @@ impl Service {
}
InsertResult::ValueUpdated | InsertResult::UpdatedPending => {}
InsertResult::Failed(reason) => {
// On large networks with limited IPv6 nodes, it is hard to get enough
// PONG votes in order to estimate our external IP address. Often the
// routing table can be full, and so we reject useful IPv6 here.
//
// If we are low on votes and we initiated this connection (i.e it was not
// forced on us) then lets get a PONG from this node.

if direction == ConnectionDirection::Outgoing {
if let Some(ip_votes) = self.ip_votes.as_mut() {
match (ip_votes.majority(), enr.udp4_socket(), enr.udp6_socket()) {
// We don't have enough ipv4 votes, but this is an IPv4 node.
((None, Some(_)), Some(_), _) |
// We don't have enough ipv6 votes, but this is an IPv6 node
((Some(_), None), _, Some(_)) |
// We don't have enough ipv6 or ipv4 nodes, ping this peer
((None, None), _, _) => self.send_ping(enr, None),
// We have enough votes do nothing
((_, _), _, _) => {}
}
}
}

self.peers_to_ping.remove(&node_id);
trace!(%node_id, ?reason, "Could not insert node");
}
Expand Down

0 comments on commit b8b1eaf

Please sign in to comment.