Skip to content

Commit

Permalink
expand common logs, unify info on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
divagant-martian committed Dec 10, 2023
1 parent 8c89fed commit 020d2ce
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl Service {
ip_mode,
};

info!("Discv5 Service started");
info!(mode = ?service.ip_mode, "Discv5 Service started");
service.start().await;
}));

Expand All @@ -333,7 +333,6 @@ impl Service {

/// The main execution loop of the discv5 serviced.
async fn start(&mut self) {
info!("{:?}", self.ip_mode);
loop {
tokio::select! {
_ = &mut self.exit => {
Expand Down Expand Up @@ -722,10 +721,9 @@ impl Service {

if nodes.len() < before_len {
// Peer sent invalid ENRs. Blacklist the Node
warn!(
"Peer sent invalid ENR. Blacklisting {}",
active_request.contact
);
let node_id = active_request.contact.node_id();
let addr = active_request.contact.socket_addr();
warn!(%node_id, %addr, "ENRs received of unsolicited distances. Blacklisting");
let ban_timeout = self.config.ban_duration.map(|v| Instant::now() + v);
PERMIT_BAN_LIST.write().ban(node_address, ban_timeout);
}
Expand Down Expand Up @@ -1449,13 +1447,14 @@ impl Service {
match active_request.request_body {
// if a failed FindNodes request, ensure we haven't partially received packets. If
// so, process the partially found nodes
RequestBody::FindNode { .. } => {
RequestBody::FindNode { ref distances } => {
if let Some(nodes_response) = self.active_nodes_responses.remove(&id) {
if !nodes_response.received_nodes.is_empty() {
warn!(
"NODES Response failed, but was partially processed from: {}",
active_request.contact
);
let node_id = active_request.contact.node_id();
let addr = active_request.contact.socket_addr();
let received = nodes_response.received_nodes.len();
let expected = distances.len();
warn!(%node_id, %addr, %error, %received, %expected, "FINDNODE request failed with partial results");
// if it's a query mark it as success, to process the partial
// collection of peers
self.discovered(
Expand Down

0 comments on commit 020d2ce

Please sign in to comment.