mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-03-01 11:11:14 -05:00
Improve network logging
This commit is contained in:
parent
f84cd001b5
commit
c25d5ff07e
@ -324,7 +324,7 @@ impl Behaviour {
|
|||||||
swap_response: SwapResponse,
|
swap_response: SwapResponse,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.amounts.send(channel, swap_response)?;
|
self.amounts.send(channel, swap_response)?;
|
||||||
info!("Sent amounts response");
|
info!("Sent swap response");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ impl EventLoop {
|
|||||||
},
|
},
|
||||||
transfer_proof = self.send_transfer_proof.recv().fuse() => {
|
transfer_proof = self.send_transfer_proof.recv().fuse() => {
|
||||||
if let Some((bob_peer_id, msg)) = transfer_proof {
|
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);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ impl Behaviour {
|
|||||||
let msg = AliceToBob::Message0(Box::new(msg));
|
let msg = AliceToBob::Message0(Box::new(msg));
|
||||||
self.rr
|
self.rr
|
||||||
.send_response(channel, msg)
|
.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(
|
fn poll(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -112,7 +112,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
error!("Outbound failure: {:?}", error);
|
error!("Outbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
RequestResponseEvent::ResponseSent { .. } => {
|
RequestResponseEvent::ResponseSent { .. } => {
|
||||||
debug!("Alice has sent an Message0 response to Bob");
|
debug!("Alice has sent Message0 as response to Bob");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ impl Behaviour {
|
|||||||
let msg = AliceToBob::Message1(Box::new(msg));
|
let msg = AliceToBob::Message1(Box::new(msg));
|
||||||
self.rr
|
self.rr
|
||||||
.send_response(channel, msg)
|
.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(
|
fn poll(
|
||||||
|
@ -97,7 +97,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
error!("Outbound failure: {:?}", error);
|
error!("Outbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
RequestResponseEvent::ResponseSent { .. } => {
|
RequestResponseEvent::ResponseSent { .. } => {
|
||||||
debug!("Alice has sent an Message2 response to Bob");
|
debug!("Alice has sent a Message2 response to Bob");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
use crate::{
|
||||||
|
monero,
|
||||||
|
network::request_response::{AliceToBob, BobToAlice, Codec, Swap, TIMEOUT},
|
||||||
|
protocol::bob,
|
||||||
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use libp2p::{
|
use libp2p::{
|
||||||
request_response::{
|
request_response::{
|
||||||
@ -15,12 +20,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
|
|
||||||
use crate::{
|
|
||||||
monero,
|
|
||||||
network::request_response::{AliceToBob, BobToAlice, Codec, Swap, TIMEOUT},
|
|
||||||
protocol::bob,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct OutEvent {
|
pub struct OutEvent {
|
||||||
pub msg: bob::SwapRequest,
|
pub msg: bob::SwapRequest,
|
||||||
@ -109,7 +108,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
error!("Outbound failure: {:?}", error);
|
error!("Outbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
RequestResponseEvent::ResponseSent { .. } => {
|
RequestResponseEvent::ResponseSent { .. } => {
|
||||||
debug!("Alice has sent an Amounts response to Bob");
|
debug!("Alice has sent a swap response to Bob");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<Request, Response>> for B
|
|||||||
error!("Outbound failure: {:?}", error);
|
error!("Outbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
RequestResponseEvent::ResponseSent { .. } => {
|
RequestResponseEvent::ResponseSent { .. } => {
|
||||||
unreachable!("Bob should never send a Amounts response to Alice");
|
unreachable!("Bob does not send the encrypted signature response to Alice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
error!("Outbound failure: {:?}", error);
|
error!("Outbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
RequestResponseEvent::ResponseSent { .. } => {
|
RequestResponseEvent::ResponseSent { .. } => {
|
||||||
unreachable!("Bob should never send a Amounts response to Alice");
|
unreachable!("Bob does not send a message0 response to Alice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
error!("Outbound failure: {:?}", error);
|
error!("Outbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
RequestResponseEvent::ResponseSent { .. } => {
|
RequestResponseEvent::ResponseSent { .. } => {
|
||||||
unreachable!("Bob should never send a Amounts response to Alice");
|
unreachable!("Bob does not send a message 1 response to Alice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
error!("Outbound failure: {:?}", error);
|
error!("Outbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
RequestResponseEvent::ResponseSent { .. } => {
|
RequestResponseEvent::ResponseSent { .. } => {
|
||||||
unreachable!("Bob should never send a Amounts response to Alice");
|
unreachable!("Bob does not send a Message2 response to Alice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
error!("Outbound failure: {:?}", error);
|
error!("Outbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
RequestResponseEvent::ResponseSent { .. } => {
|
RequestResponseEvent::ResponseSent { .. } => {
|
||||||
error!("Bob should never send a Amounts response to Alice");
|
error!("Bob does not send a swap response to Alice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,10 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<Request, Response>> for B
|
|||||||
debug!("Received Transfer Proof");
|
debug!("Received Transfer Proof");
|
||||||
self.events.push_back(OutEvent::Msg(*msg));
|
self.events.push_back(OutEvent::Msg(*msg));
|
||||||
// Send back empty response so that the request/response protocol completes.
|
// 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 {
|
RequestResponseEvent::Message {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user