mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat(discv4): neighbors packet logging (#12042)
Co-authored-by: Oliver Nordbjerg <hi@notbjerg.me>
This commit is contained in:
@ -42,6 +42,7 @@ parking_lot.workspace = true
|
||||
rand = { workspace = true, optional = true }
|
||||
generic-array.workspace = true
|
||||
serde = { workspace = true, optional = true }
|
||||
itertools.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
assert_matches.workspace = true
|
||||
|
||||
@ -38,6 +38,7 @@ use discv5::{
|
||||
ConnectionDirection, ConnectionState,
|
||||
};
|
||||
use enr::Enr;
|
||||
use itertools::Itertools;
|
||||
use parking_lot::Mutex;
|
||||
use proto::{EnrRequest, EnrResponse};
|
||||
use reth_ethereum_forks::ForkId;
|
||||
@ -861,7 +862,7 @@ impl Discv4Service {
|
||||
let Some(bucket) = self.kbuckets.get_bucket(&key) else { return false };
|
||||
if bucket.num_entries() < MAX_NODES_PER_BUCKET / 2 {
|
||||
// skip half empty bucket
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
self.remove_key(node_id, key)
|
||||
}
|
||||
@ -1406,6 +1407,16 @@ impl Discv4Service {
|
||||
}
|
||||
};
|
||||
|
||||
// log the peers we discovered
|
||||
trace!(target: "discv4",
|
||||
target=format!("{:#?}", node_id),
|
||||
peers_count=msg.nodes.len(),
|
||||
peers=format!("[{:#}]", msg.nodes.iter()
|
||||
.map(|node_rec| node_rec.id
|
||||
).format(", ")),
|
||||
"Received peers from Neighbours packet"
|
||||
);
|
||||
|
||||
// This is the recursive lookup step where we initiate new FindNode requests for new nodes
|
||||
// that were discovered.
|
||||
for node in msg.nodes.into_iter().map(NodeRecord::into_ipv4_mapped) {
|
||||
|
||||
Reference in New Issue
Block a user