Skip to content

Commit

Permalink
Revert "Prevent storing non-contactable ENRs (sigp#246)"
Browse files Browse the repository at this point in the history
This reverts commit 10cf228.
  • Loading branch information
KolbyML committed Jan 16, 2025
1 parent 07572ef commit 6f35a1b
Showing 1 changed file with 7 additions and 31 deletions.
38 changes: 7 additions & 31 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,13 +886,7 @@ impl Service {
};
self.send_rpc_request(active_request);
}
// Only update the routing table if the new ENR is contactable
if self.ip_mode.get_contactable_addr(&enr).is_some() {
self.connection_updated(
node_id,
ConnectionStatus::PongReceived(enr),
);
}
self.connection_updated(node_id, ConnectionStatus::PongReceived(enr));
}
}
}
Expand Down Expand Up @@ -1194,19 +1188,16 @@ impl Service {
return false;
}

// If any of the discovered nodes are in the routing table, and there contains an older ENR, update it.
// If there is an event stream send the Discovered event
if self.config.report_discovered_peers {
self.send_event(Event::Discovered(enr.clone()));
}

// Check that peers are compatible to be included into the routing table. They must:
// - Pass the table filter
// - Be contactable
//
// Failing this, they are not added, and if there is an older version of them in our
// table, we remove them.
let key = kbucket::Key::from(enr.node_id());
if (self.config.table_filter)(enr) && self.ip_mode.get_contactable_addr(enr).is_some() {
// ignore peers that don't pass the table filter
if (self.config.table_filter)(enr) {
let key = kbucket::Key::from(enr.node_id());

// If the ENR exists in the routing table and the discovered ENR has a greater
// sequence number, perform some filter checks before updating the enr.

Expand All @@ -1230,22 +1221,7 @@ impl Service {
}
}
} else {
// Is either non-contactable or didn't pass the table filter. If it exists in the
// routing table, remove it.
match self.kbuckets.write().entry(&key) {
kbucket::Entry::Present(entry, _) if entry.value().seq() < enr.seq() => {
entry.remove()
}
kbucket::Entry::Pending(mut entry, _) => {
if entry.value().seq() < enr.seq() {
entry.remove()
}
}
_ => {}
}

// Didn't pass the requirements remove the ENR
return false;
return false; // Didn't pass the table filter remove the peer
}

// The remaining ENRs are used if this request was part of a query. If we are
Expand Down

0 comments on commit 6f35a1b

Please sign in to comment.