Skip to content

Commit ce7531c

Browse files
Adjust some logs (#225)
* remove log for timed out query. This is always informed in the callback * expand common logs, unify info on startup * adjust auth header log * Update src/service.rs * Appease clippy * Realised I was wrong. Don't need this log, my bad * fmt --------- Co-authored-by: Age Manning <[email protected]>
1 parent 546e19c commit ce7531c

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/handler/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,8 @@ impl Handler {
908908
}
909909
} else {
910910
warn!(
911-
"Received an authenticated header without a matching WHOAREYOU request. {}",
912-
node_address
911+
node_id = %node_address.node_id, addr = %node_address.socket_addr,
912+
"Received an authenticated header without a matching WHOAREYOU request",
913913
);
914914
}
915915
}

src/service.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl Service {
324324
ip_mode,
325325
};
326326

327-
info!("Discv5 Service started");
327+
info!(mode = ?service.ip_mode, "Discv5 Service started");
328328
service.start().await;
329329
}));
330330

@@ -333,7 +333,6 @@ impl Service {
333333

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

723722
if nodes.len() < before_len {
724723
// Peer sent invalid ENRs. Blacklist the Node
725-
warn!(
726-
"Peer sent invalid ENR. Blacklisting {}",
727-
active_request.contact
728-
);
724+
let node_id = active_request.contact.node_id();
725+
let addr = active_request.contact.socket_addr();
726+
warn!(%node_id, %addr, "ENRs received of unsolicited distances. Blacklisting");
729727
let ban_timeout = self.config.ban_duration.map(|v| Instant::now() + v);
730728
PERMIT_BAN_LIST.write().ban(node_address, ban_timeout);
731729
}
@@ -1449,13 +1447,14 @@ impl Service {
14491447
match active_request.request_body {
14501448
// if a failed FindNodes request, ensure we haven't partially received packets. If
14511449
// so, process the partially found nodes
1452-
RequestBody::FindNode { .. } => {
1450+
RequestBody::FindNode { ref distances } => {
14531451
if let Some(nodes_response) = self.active_nodes_responses.remove(&id) {
14541452
if !nodes_response.received_nodes.is_empty() {
1455-
warn!(
1456-
"NODES Response failed, but was partially processed from: {}",
1457-
active_request.contact
1458-
);
1453+
let node_id = active_request.contact.node_id();
1454+
let addr = active_request.contact.socket_addr();
1455+
let received = nodes_response.received_nodes.len();
1456+
let expected = distances.len();
1457+
warn!(%node_id, %addr, %error, %received, %expected, "FINDNODE request failed with partial results");
14591458
// if it's a query mark it as success, to process the partial
14601459
// collection of peers
14611460
self.discovered(
@@ -1529,10 +1528,8 @@ impl Service {
15291528
let request_body = query.target().rpc_request(return_peer);
15301529
Poll::Ready(QueryEvent::Waiting(query.id(), node_id, request_body))
15311530
}
1532-
QueryPoolState::Timeout(query) => {
1533-
warn!("Query id: {:?} timed out", query.id());
1534-
Poll::Ready(QueryEvent::TimedOut(Box::new(query)))
1535-
}
1531+
1532+
QueryPoolState::Timeout(query) => Poll::Ready(QueryEvent::TimedOut(Box::new(query))),
15361533
QueryPoolState::Waiting(None) | QueryPoolState::Idle => Poll::Pending,
15371534
})
15381535
.await

0 commit comments

Comments
 (0)