mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-04-20 07:56:05 -04:00
Improve/fix error handling/logging
This commit is contained in:
parent
a5af3e22ac
commit
761fd7959f
@ -118,10 +118,6 @@ impl WatchForTransfer for Wallet {
|
||||
let confirmations = Arc::new(AtomicU32::new(0u32));
|
||||
|
||||
let res = retry(ConstantBackoff::new(Duration::from_secs(1)), || async {
|
||||
let confirmations = confirmations.clone();
|
||||
let transfer_proof = transfer_proof.clone();
|
||||
let wallet = wallet.clone();
|
||||
|
||||
// NOTE: Currently, this is conflicting IO errors with the transaction not being
|
||||
// in the blockchain yet, or not having enough confirmations on it. All these
|
||||
// errors warrant a retry, but the strategy should probably differ per case
|
||||
|
@ -309,7 +309,7 @@ impl Behaviour {
|
||||
channel: ResponseChannel<AliceToBob>,
|
||||
swap_response: SwapResponse,
|
||||
) -> Result<()> {
|
||||
let _ = self.amounts.send(channel, swap_response)?;
|
||||
self.amounts.send(channel, swap_response)?;
|
||||
info!("Sent amounts response");
|
||||
Ok(())
|
||||
}
|
||||
@ -320,7 +320,7 @@ impl Behaviour {
|
||||
channel: ResponseChannel<AliceToBob>,
|
||||
msg: Message0,
|
||||
) -> Result<()> {
|
||||
let _ = self.message0.send(channel, msg)?;
|
||||
self.message0.send(channel, msg)?;
|
||||
debug!("Sent Message0");
|
||||
Ok(())
|
||||
}
|
||||
@ -331,7 +331,7 @@ impl Behaviour {
|
||||
channel: ResponseChannel<AliceToBob>,
|
||||
msg: Message1,
|
||||
) -> Result<()> {
|
||||
let _ = self.message1.send(channel, msg)?;
|
||||
self.message1.send(channel, msg)?;
|
||||
debug!("Sent Message1");
|
||||
Ok(())
|
||||
}
|
||||
@ -342,7 +342,7 @@ impl Behaviour {
|
||||
channel: ResponseChannel<AliceToBob>,
|
||||
msg: Message2,
|
||||
) -> Result<()> {
|
||||
let _ = self.message2.send(channel, msg)?;
|
||||
self.message2.send(channel, msg)?;
|
||||
debug!("Sent Message2");
|
||||
Ok(())
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use libp2p::{
|
||||
core::Multiaddr, futures::FutureExt, request_response::ResponseChannel, PeerId, Swarm,
|
||||
};
|
||||
use tokio::sync::mpsc::{Receiver, Sender};
|
||||
use tracing::error;
|
||||
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Channels<T> {
|
||||
@ -229,22 +230,34 @@ impl EventLoop {
|
||||
},
|
||||
swap_response = self.send_swap_response.recv().fuse() => {
|
||||
if let Some((channel, swap_response)) = swap_response {
|
||||
self.swarm.send_swap_response(channel, swap_response).expect("Could not send amounts message");
|
||||
let _ = self
|
||||
.swarm
|
||||
.send_swap_response(channel, swap_response)
|
||||
.map_err(|err|error!("Failed to send swap response: {:#}", err));
|
||||
}
|
||||
},
|
||||
msg0 = self.send_msg0.recv().fuse() => {
|
||||
if let Some((channel, msg)) = msg0 {
|
||||
self.swarm.send_message0(channel, msg).expect("Could not send message0");
|
||||
let _ = self
|
||||
.swarm
|
||||
.send_message0(channel, msg)
|
||||
.map_err(|err|error!("Failed to send message0: {:#}", err));
|
||||
}
|
||||
},
|
||||
msg1 = self.send_msg1.recv().fuse() => {
|
||||
if let Some((channel, msg)) = msg1 {
|
||||
self.swarm.send_message1(channel, msg).expect("Could not send message1");
|
||||
let _ = self
|
||||
.swarm
|
||||
.send_message1(channel, msg)
|
||||
.map_err(|err|error!("Failed to send message1: {:#}", err));
|
||||
}
|
||||
},
|
||||
msg2 = self.send_msg2.recv().fuse() => {
|
||||
if let Some((channel, msg)) = msg2 {
|
||||
self.swarm.send_message2(channel, msg).expect("Could not send message2");
|
||||
let _ = self
|
||||
.swarm
|
||||
.send_message2(channel, msg)
|
||||
.map_err(|err|error!("Failed to send message2: {:#}", err));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
error!("Outbound failure: {:?}", error);
|
||||
}
|
||||
RequestResponseEvent::ResponseSent { .. } => {
|
||||
error!("Bob should never send a Amounts response to Alice");
|
||||
unreachable!("Bob should never send a Amounts response to Alice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
error!("Outbound failure: {:?}", error);
|
||||
}
|
||||
RequestResponseEvent::ResponseSent { .. } => {
|
||||
error!("Bob should never send a Amounts response to Alice");
|
||||
unreachable!("Bob should never send a Amounts response to Alice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
error!("Outbound failure: {:?}", error);
|
||||
}
|
||||
RequestResponseEvent::ResponseSent { .. } => {
|
||||
error!("Bob should never send a Amounts response to Alice");
|
||||
unreachable!("Bob should never send a Amounts response to Alice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
error!("Outbound failure: {:?}", error);
|
||||
}
|
||||
RequestResponseEvent::ResponseSent { .. } => {
|
||||
error!("Bob should never send a Amounts response to Alice");
|
||||
unreachable!("Bob should never send a Amounts response to Alice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user