mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 15:09:35 -05:00
Do not trace events meant for other NBs
This commit is contained in:
parent
c464555f5e
commit
3e2f0b74a2
@ -94,6 +94,8 @@ pub async fn swap(
|
||||
}
|
||||
}
|
||||
|
||||
debug!("swapping ...");
|
||||
|
||||
let mut swarm = new_swarm(listen, local_port)?;
|
||||
let message0: bob::Message0;
|
||||
let mut last_amounts: Option<SwapAmounts> = None;
|
||||
@ -112,6 +114,7 @@ pub async fn swap(
|
||||
swarm.send_amounts(channel, amounts);
|
||||
}
|
||||
OutEvent::Message0(msg) => {
|
||||
debug!("got message 0 from Bob");
|
||||
// We don't want Bob to be able to crash us by sending an out of
|
||||
// order message. Keep looping if Bob has not requested amounts.
|
||||
if last_amounts.is_some() {
|
||||
|
@ -11,7 +11,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||
|
||||
@ -79,12 +79,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
request, channel, ..
|
||||
},
|
||||
..
|
||||
} => match request {
|
||||
BobToAlice::AmountsFromBtc(btc) => {
|
||||
} => {
|
||||
if let BobToAlice::AmountsFromBtc(btc) = request {
|
||||
self.events.push_back(OutEvent::Btc { btc, channel })
|
||||
}
|
||||
other => debug!("got request: {:?}", other),
|
||||
},
|
||||
}
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { .. },
|
||||
..
|
||||
|
@ -13,7 +13,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tracing::{debug, error, info};
|
||||
use tracing::{error, info};
|
||||
|
||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||
use xmr_btc::{alice::State0, bob};
|
||||
@ -85,8 +85,8 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
request, channel, ..
|
||||
},
|
||||
..
|
||||
} => match request {
|
||||
BobToAlice::Message0(msg) => {
|
||||
} => {
|
||||
if let BobToAlice::Message0(msg) = request {
|
||||
info!("Got Alice's first message");
|
||||
let response = match &self.state {
|
||||
None => panic!("No state, did you forget to set it?"),
|
||||
@ -98,8 +98,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
self.rr.send_response(channel, response);
|
||||
self.events.push_back(OutEvent::Msg(msg));
|
||||
}
|
||||
other => debug!("got request: {:?}", other),
|
||||
},
|
||||
}
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { .. },
|
||||
..
|
||||
|
@ -11,7 +11,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||
use xmr_btc::bob;
|
||||
@ -81,12 +81,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
request, channel, ..
|
||||
},
|
||||
..
|
||||
} => match request {
|
||||
BobToAlice::Message1(msg) => {
|
||||
} => {
|
||||
if let BobToAlice::Message1(msg) = request {
|
||||
self.events.push_back(OutEvent::Msg { msg, channel });
|
||||
}
|
||||
other => debug!("got request: {:?}", other),
|
||||
},
|
||||
}
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { .. },
|
||||
..
|
||||
|
@ -11,7 +11,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||
use xmr_btc::bob;
|
||||
@ -81,12 +81,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
request, channel, ..
|
||||
},
|
||||
..
|
||||
} => match request {
|
||||
BobToAlice::Message2(msg) => {
|
||||
} => {
|
||||
if let BobToAlice::Message2(msg) = request {
|
||||
self.events.push_back(OutEvent::Msg { msg, channel });
|
||||
}
|
||||
other => debug!("got request: {:?}", other),
|
||||
},
|
||||
}
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { .. },
|
||||
..
|
||||
|
@ -11,7 +11,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||
use xmr_btc::bob;
|
||||
@ -71,14 +71,13 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
request, channel, ..
|
||||
},
|
||||
..
|
||||
} => match request {
|
||||
BobToAlice::Message3(msg) => {
|
||||
} => {
|
||||
if let BobToAlice::Message3(msg) = request {
|
||||
self.events.push_back(OutEvent::Msg(msg));
|
||||
// Send back empty response so that the request/response protocol completes.
|
||||
self.rr.send_response(channel, AliceToBob::Message3);
|
||||
}
|
||||
other => debug!("got request: {:?}", other),
|
||||
},
|
||||
}
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { .. },
|
||||
..
|
||||
|
@ -12,7 +12,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::{
|
||||
network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT},
|
||||
@ -83,10 +83,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { response, .. },
|
||||
..
|
||||
} => match response {
|
||||
AliceToBob::Amounts(p) => self.events.push_back(OutEvent::Amounts(p)),
|
||||
other => debug!("got response: {:?}", other),
|
||||
},
|
||||
} => {
|
||||
if let AliceToBob::Amounts(p) = response {
|
||||
self.events.push_back(OutEvent::Amounts(p));
|
||||
}
|
||||
}
|
||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||
error!("Inbound failure: {:?}", error);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||
use xmr_btc::{alice, bob};
|
||||
@ -77,10 +77,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { response, .. },
|
||||
..
|
||||
} => match response {
|
||||
AliceToBob::Message0(msg) => self.events.push_back(OutEvent::Msg(msg)),
|
||||
other => debug!("got response: {:?}", other),
|
||||
},
|
||||
} => {
|
||||
if let AliceToBob::Message0(msg) = response {
|
||||
self.events.push_back(OutEvent::Msg(msg));
|
||||
}
|
||||
}
|
||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||
error!("Inbound failure: {:?}", error);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||
use xmr_btc::{alice, bob};
|
||||
@ -77,10 +77,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { response, .. },
|
||||
..
|
||||
} => match response {
|
||||
AliceToBob::Message1(msg) => self.events.push_back(OutEvent::Msg(msg)),
|
||||
other => debug!("got response: {:?}", other),
|
||||
},
|
||||
} => {
|
||||
if let AliceToBob::Message1(msg) = response {
|
||||
self.events.push_back(OutEvent::Msg(msg));
|
||||
}
|
||||
}
|
||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||
error!("Inbound failure: {:?}", error);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
use tracing::error;
|
||||
|
||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||
use xmr_btc::{alice, bob};
|
||||
@ -77,10 +77,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { response, .. },
|
||||
..
|
||||
} => match response {
|
||||
AliceToBob::Message2(msg) => self.events.push_back(OutEvent::Msg(msg)),
|
||||
other => debug!("unexpected response: {:?}", other),
|
||||
},
|
||||
} => {
|
||||
if let AliceToBob::Message2(msg) = response {
|
||||
self.events.push_back(OutEvent::Msg(msg));
|
||||
}
|
||||
}
|
||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||
error!("Inbound failure: {:?}", error);
|
||||
}
|
||||
|
@ -69,10 +69,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
||||
RequestResponseEvent::Message {
|
||||
message: RequestResponseMessage::Response { response, .. },
|
||||
..
|
||||
} => match response {
|
||||
AliceToBob::Message3 => debug!("Alice correctly responded to message 3"),
|
||||
other => debug!("unexpected response: {:?}", other),
|
||||
},
|
||||
} => {
|
||||
if let AliceToBob::Message3 = response {
|
||||
debug!("Alice correctly responded to message 3");
|
||||
}
|
||||
}
|
||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||
error!("Inbound failure: {:?}", error);
|
||||
}
|
||||
|
@ -57,7 +57,12 @@ async fn swap() {
|
||||
let alice_xmr_wallet = Arc::new(swap::monero::Wallet(monero.alice_wallet_rpc_client()));
|
||||
let bob_xmr_wallet = Arc::new(swap::monero::Wallet(monero.bob_wallet_rpc_client()));
|
||||
|
||||
let alice_swap = alice::swap(alice_btc_wallet, alice_xmr_wallet, alice_multiaddr.clone());
|
||||
let alice_swap = alice::swap(
|
||||
alice_btc_wallet,
|
||||
alice_xmr_wallet,
|
||||
alice_multiaddr.clone(),
|
||||
None,
|
||||
);
|
||||
|
||||
let (cmd_tx, mut _cmd_rx) = mpsc::channel(1);
|
||||
let (mut rsp_tx, rsp_rx) = mpsc::channel(1);
|
||||
|
Loading…
Reference in New Issue
Block a user