public address detection work

This commit is contained in:
John Smith
2022-08-26 22:52:08 -04:00
parent 75094bb6be
commit 32d3388bd9
14 changed files with 242 additions and 110 deletions
+11 -1
View File
@@ -290,6 +290,7 @@ impl RoutingTable {
// Public dial info changed, go through all nodes and reset their 'seen our node info' bit
if matches!(domain, RoutingDomain::PublicInternet) {
Self::reset_all_seen_our_node_info(&*inner);
Self::reset_all_updated_since_last_network_change(&*inner);
}
Ok(())
@@ -303,6 +304,14 @@ impl RoutingTable {
});
}
fn reset_all_updated_since_last_network_change(inner: &RoutingTableInner) {
let cur_ts = intf::get_timestamp();
Self::with_entries(&*inner, cur_ts, BucketEntryState::Dead, |_, v| {
v.with_mut(|e| e.set_updated_since_last_network_change(false));
Option::<()>::None
});
}
pub fn clear_dial_info_details(&self, domain: RoutingDomain) {
trace!("clearing dial info domain: {:?}", domain);
@@ -587,6 +596,7 @@ impl RoutingTable {
&self,
node_id: DHTKey,
signed_node_info: SignedNodeInfo,
allow_invalid_signature: bool,
) -> Option<NodeRef> {
// validate signed node info is not something malicious
if node_id == self.node_id() {
@@ -601,7 +611,7 @@ impl RoutingTable {
}
self.create_node_ref(node_id, |e| {
if e.update_node_info(signed_node_info) {
if e.update_signed_node_info(signed_node_info, allow_invalid_signature) {
// at least someone thought this node was live and its node info changed so lets try to contact it
e.touch_last_seen(intf::get_timestamp());
}