Skip to content

Commit

Permalink
[network-rpc] structure network rpc request log. (starcoinorg#2368)
Browse files Browse the repository at this point in the history
  • Loading branch information
jolestar authored and naughtyvenom committed Jul 19, 2021
1 parent 4fc1a0d commit 295278f
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions network-p2p/src/request_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ impl RequestResponsesBehaviour {
(protocol_name.to_string().into(), request_id).into(),
(Instant::now(), pending_response),
);
info!(
"[network-p2p] req-resp send request {} {} {} {}",
info!(target:"network-rpc-client",
"{} {} {} {}",
request_id, target, protocol_name, len,
);
debug_assert!(prev_req_id.is_none(), "Expect request id to be unique.");
Expand Down Expand Up @@ -581,22 +581,18 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
},
..
} => {
let (started, delivered) = match self
let (started, delivered, response_len) = match self
.pending_requests
.remove(&(protocol.clone(), request_id).into())
{
Some((started, pending_response)) => {
if let Ok(response) = &response {
info!(
"[network-p2p] req-resp received response {} {}",
request_id,
response.len()
);
};
let response_len =
response.as_ref().map(|resp| resp.len()).unwrap_or(0);
let delivered = pending_response
.send(response.map_err(|()| RequestFailure::Refused))
.map_err(|_| RequestFailure::Obsolete);
(started, delivered)

(started, delivered, response_len)
}
None => {
log::warn!(
Expand All @@ -609,6 +605,16 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
}
};

info!(target:
"network-rpc-client",
"{} {} {} {} {}",
request_id,
protocol,
response_len,
delivered.is_ok(),
started.elapsed().as_millis(),
);

let out = Event::RequestFinished {
peer,
protocol: protocol.clone(),
Expand Down

0 comments on commit 295278f

Please sign in to comment.