Improve network logging

This commit is contained in:
Franck Royer 2021-01-22 09:38:04 +11:00
parent f84cd001b5
commit c25d5ff07e
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
12 changed files with 21 additions and 19 deletions

View File

@ -324,7 +324,7 @@ impl Behaviour {
swap_response: SwapResponse,
) -> Result<()> {
self.amounts.send(channel, swap_response)?;
info!("Sent amounts response");
info!("Sent swap response");
Ok(())
}

View File

@ -265,7 +265,7 @@ impl EventLoop {
},
transfer_proof = self.send_transfer_proof.recv().fuse() => {
if let Some((bob_peer_id, msg)) = transfer_proof {
self.swarm.send_transfer_proof(bob_peer_id, msg)
self.swarm.send_transfer_proof(bob_peer_id, msg);
}
},
}

View File

@ -54,7 +54,7 @@ impl Behaviour {
let msg = AliceToBob::Message0(Box::new(msg));
self.rr
.send_response(channel, msg)
.map_err(|_| anyhow!("Sending Amounts response failed"))
.map_err(|alice_to_bob| anyhow!("Could not send response {:?}", alice_to_bob))
}
fn poll(
&mut self,
@ -112,7 +112,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
error!("Outbound failure: {:?}", error);
}
RequestResponseEvent::ResponseSent { .. } => {
debug!("Alice has sent an Message0 response to Bob");
debug!("Alice has sent Message0 as response to Bob");
}
}
}

View File

@ -51,7 +51,7 @@ impl Behaviour {
let msg = AliceToBob::Message1(Box::new(msg));
self.rr
.send_response(channel, msg)
.map_err(|_| anyhow!("Sending Amounts response failed"))
.map_err(|alice_to_bob| anyhow!("Could not send response {:?}", alice_to_bob))
}
fn poll(

View File

@ -97,7 +97,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
error!("Outbound failure: {:?}", error);
}
RequestResponseEvent::ResponseSent { .. } => {
debug!("Alice has sent an Message2 response to Bob");
debug!("Alice has sent a Message2 response to Bob");
}
}
}

View File

@ -1,3 +1,8 @@
use crate::{
monero,
network::request_response::{AliceToBob, BobToAlice, Codec, Swap, TIMEOUT},
protocol::bob,
};
use anyhow::{anyhow, Result};
use libp2p::{
request_response::{
@ -15,12 +20,6 @@ use std::{
};
use tracing::{debug, error};
use crate::{
monero,
network::request_response::{AliceToBob, BobToAlice, Codec, Swap, TIMEOUT},
protocol::bob,
};
#[derive(Debug)]
pub struct OutEvent {
pub msg: bob::SwapRequest,
@ -109,7 +108,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
error!("Outbound failure: {:?}", error);
}
RequestResponseEvent::ResponseSent { .. } => {
debug!("Alice has sent an Amounts response to Bob");
debug!("Alice has sent a swap response to Bob");
}
}
}

View File

@ -97,7 +97,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<Request, Response>> for B
error!("Outbound failure: {:?}", error);
}
RequestResponseEvent::ResponseSent { .. } => {
unreachable!("Bob should never send a Amounts response to Alice");
unreachable!("Bob does not send the encrypted signature response to Alice");
}
}
}

View File

@ -103,7 +103,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
error!("Outbound failure: {:?}", error);
}
RequestResponseEvent::ResponseSent { .. } => {
unreachable!("Bob should never send a Amounts response to Alice");
unreachable!("Bob does not send a message0 response to Alice");
}
}
}

View File

@ -98,7 +98,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
error!("Outbound failure: {:?}", error);
}
RequestResponseEvent::ResponseSent { .. } => {
unreachable!("Bob should never send a Amounts response to Alice");
unreachable!("Bob does not send a message 1 response to Alice");
}
}
}

View File

@ -96,7 +96,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
error!("Outbound failure: {:?}", error);
}
RequestResponseEvent::ResponseSent { .. } => {
unreachable!("Bob should never send a Amounts response to Alice");
unreachable!("Bob does not send a Message2 response to Alice");
}
}
}

View File

@ -104,7 +104,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
error!("Outbound failure: {:?}", error);
}
RequestResponseEvent::ResponseSent { .. } => {
error!("Bob should never send a Amounts response to Alice");
error!("Bob does not send a swap response to Alice");
}
}
}

View File

@ -79,7 +79,10 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<Request, Response>> for B
debug!("Received Transfer Proof");
self.events.push_back(OutEvent::Msg(*msg));
// Send back empty response so that the request/response protocol completes.
let _ = self.rr.send_response(channel, Response::TransferProof);
let _ = self
.rr
.send_response(channel, Response::TransferProof)
.map_err(|err| error!("Failed to send message 3: {:?}", err));
}
}
RequestResponseEvent::Message {