mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04: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 mut swarm = new_swarm(listen, local_port)?;
|
||||||
let message0: bob::Message0;
|
let message0: bob::Message0;
|
||||||
let mut last_amounts: Option<SwapAmounts> = None;
|
let mut last_amounts: Option<SwapAmounts> = None;
|
||||||
@ -112,6 +114,7 @@ pub async fn swap(
|
|||||||
swarm.send_amounts(channel, amounts);
|
swarm.send_amounts(channel, amounts);
|
||||||
}
|
}
|
||||||
OutEvent::Message0(msg) => {
|
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
|
// 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.
|
// order message. Keep looping if Bob has not requested amounts.
|
||||||
if last_amounts.is_some() {
|
if last_amounts.is_some() {
|
||||||
|
@ -11,7 +11,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::error;
|
||||||
|
|
||||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||||
|
|
||||||
@ -79,12 +79,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
request, channel, ..
|
request, channel, ..
|
||||||
},
|
},
|
||||||
..
|
..
|
||||||
} => match request {
|
} => {
|
||||||
BobToAlice::AmountsFromBtc(btc) => {
|
if let BobToAlice::AmountsFromBtc(btc) = request {
|
||||||
self.events.push_back(OutEvent::Btc { btc, channel })
|
self.events.push_back(OutEvent::Btc { btc, channel })
|
||||||
}
|
}
|
||||||
other => debug!("got request: {:?}", other),
|
}
|
||||||
},
|
|
||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { .. },
|
message: RequestResponseMessage::Response { .. },
|
||||||
..
|
..
|
||||||
|
@ -13,7 +13,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||||
use xmr_btc::{alice::State0, bob};
|
use xmr_btc::{alice::State0, bob};
|
||||||
@ -85,8 +85,8 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
request, channel, ..
|
request, channel, ..
|
||||||
},
|
},
|
||||||
..
|
..
|
||||||
} => match request {
|
} => {
|
||||||
BobToAlice::Message0(msg) => {
|
if let BobToAlice::Message0(msg) = request {
|
||||||
info!("Got Alice's first message");
|
info!("Got Alice's first message");
|
||||||
let response = match &self.state {
|
let response = match &self.state {
|
||||||
None => panic!("No state, did you forget to set it?"),
|
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.rr.send_response(channel, response);
|
||||||
self.events.push_back(OutEvent::Msg(msg));
|
self.events.push_back(OutEvent::Msg(msg));
|
||||||
}
|
}
|
||||||
other => debug!("got request: {:?}", other),
|
}
|
||||||
},
|
|
||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { .. },
|
message: RequestResponseMessage::Response { .. },
|
||||||
..
|
..
|
||||||
|
@ -11,7 +11,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::error;
|
||||||
|
|
||||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||||
use xmr_btc::bob;
|
use xmr_btc::bob;
|
||||||
@ -81,12 +81,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
request, channel, ..
|
request, channel, ..
|
||||||
},
|
},
|
||||||
..
|
..
|
||||||
} => match request {
|
} => {
|
||||||
BobToAlice::Message1(msg) => {
|
if let BobToAlice::Message1(msg) = request {
|
||||||
self.events.push_back(OutEvent::Msg { msg, channel });
|
self.events.push_back(OutEvent::Msg { msg, channel });
|
||||||
}
|
}
|
||||||
other => debug!("got request: {:?}", other),
|
}
|
||||||
},
|
|
||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { .. },
|
message: RequestResponseMessage::Response { .. },
|
||||||
..
|
..
|
||||||
|
@ -11,7 +11,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::error;
|
||||||
|
|
||||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||||
use xmr_btc::bob;
|
use xmr_btc::bob;
|
||||||
@ -81,12 +81,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
request, channel, ..
|
request, channel, ..
|
||||||
},
|
},
|
||||||
..
|
..
|
||||||
} => match request {
|
} => {
|
||||||
BobToAlice::Message2(msg) => {
|
if let BobToAlice::Message2(msg) = request {
|
||||||
self.events.push_back(OutEvent::Msg { msg, channel });
|
self.events.push_back(OutEvent::Msg { msg, channel });
|
||||||
}
|
}
|
||||||
other => debug!("got request: {:?}", other),
|
}
|
||||||
},
|
|
||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { .. },
|
message: RequestResponseMessage::Response { .. },
|
||||||
..
|
..
|
||||||
|
@ -11,7 +11,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::error;
|
||||||
|
|
||||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||||
use xmr_btc::bob;
|
use xmr_btc::bob;
|
||||||
@ -71,14 +71,13 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
request, channel, ..
|
request, channel, ..
|
||||||
},
|
},
|
||||||
..
|
..
|
||||||
} => match request {
|
} => {
|
||||||
BobToAlice::Message3(msg) => {
|
if let BobToAlice::Message3(msg) = request {
|
||||||
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.
|
||||||
self.rr.send_response(channel, AliceToBob::Message3);
|
self.rr.send_response(channel, AliceToBob::Message3);
|
||||||
}
|
}
|
||||||
other => debug!("got request: {:?}", other),
|
}
|
||||||
},
|
|
||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { .. },
|
message: RequestResponseMessage::Response { .. },
|
||||||
..
|
..
|
||||||
|
@ -12,7 +12,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::error;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT},
|
network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT},
|
||||||
@ -83,10 +83,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { response, .. },
|
message: RequestResponseMessage::Response { response, .. },
|
||||||
..
|
..
|
||||||
} => match response {
|
} => {
|
||||||
AliceToBob::Amounts(p) => self.events.push_back(OutEvent::Amounts(p)),
|
if let AliceToBob::Amounts(p) = response {
|
||||||
other => debug!("got response: {:?}", other),
|
self.events.push_back(OutEvent::Amounts(p));
|
||||||
},
|
}
|
||||||
|
}
|
||||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||||
error!("Inbound failure: {:?}", error);
|
error!("Inbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::error;
|
||||||
|
|
||||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||||
use xmr_btc::{alice, bob};
|
use xmr_btc::{alice, bob};
|
||||||
@ -77,10 +77,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { response, .. },
|
message: RequestResponseMessage::Response { response, .. },
|
||||||
..
|
..
|
||||||
} => match response {
|
} => {
|
||||||
AliceToBob::Message0(msg) => self.events.push_back(OutEvent::Msg(msg)),
|
if let AliceToBob::Message0(msg) = response {
|
||||||
other => debug!("got response: {:?}", other),
|
self.events.push_back(OutEvent::Msg(msg));
|
||||||
},
|
}
|
||||||
|
}
|
||||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||||
error!("Inbound failure: {:?}", error);
|
error!("Inbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::error;
|
||||||
|
|
||||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||||
use xmr_btc::{alice, bob};
|
use xmr_btc::{alice, bob};
|
||||||
@ -77,10 +77,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { response, .. },
|
message: RequestResponseMessage::Response { response, .. },
|
||||||
..
|
..
|
||||||
} => match response {
|
} => {
|
||||||
AliceToBob::Message1(msg) => self.events.push_back(OutEvent::Msg(msg)),
|
if let AliceToBob::Message1(msg) = response {
|
||||||
other => debug!("got response: {:?}", other),
|
self.events.push_back(OutEvent::Msg(msg));
|
||||||
},
|
}
|
||||||
|
}
|
||||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||||
error!("Inbound failure: {:?}", error);
|
error!("Inbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ use std::{
|
|||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::error;
|
||||||
|
|
||||||
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
use crate::network::request_response::{AliceToBob, BobToAlice, Codec, Protocol, TIMEOUT};
|
||||||
use xmr_btc::{alice, bob};
|
use xmr_btc::{alice, bob};
|
||||||
@ -77,10 +77,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { response, .. },
|
message: RequestResponseMessage::Response { response, .. },
|
||||||
..
|
..
|
||||||
} => match response {
|
} => {
|
||||||
AliceToBob::Message2(msg) => self.events.push_back(OutEvent::Msg(msg)),
|
if let AliceToBob::Message2(msg) = response {
|
||||||
other => debug!("unexpected response: {:?}", other),
|
self.events.push_back(OutEvent::Msg(msg));
|
||||||
},
|
}
|
||||||
|
}
|
||||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||||
error!("Inbound failure: {:?}", error);
|
error!("Inbound failure: {:?}", error);
|
||||||
}
|
}
|
||||||
|
@ -69,10 +69,11 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
RequestResponseEvent::Message {
|
RequestResponseEvent::Message {
|
||||||
message: RequestResponseMessage::Response { response, .. },
|
message: RequestResponseMessage::Response { response, .. },
|
||||||
..
|
..
|
||||||
} => match response {
|
} => {
|
||||||
AliceToBob::Message3 => debug!("Alice correctly responded to message 3"),
|
if let AliceToBob::Message3 = response {
|
||||||
other => debug!("unexpected response: {:?}", other),
|
debug!("Alice correctly responded to message 3");
|
||||||
},
|
}
|
||||||
|
}
|
||||||
RequestResponseEvent::InboundFailure { error, .. } => {
|
RequestResponseEvent::InboundFailure { error, .. } => {
|
||||||
error!("Inbound failure: {:?}", 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 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 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 (cmd_tx, mut _cmd_rx) = mpsc::channel(1);
|
||||||
let (mut rsp_tx, rsp_rx) = mpsc::channel(1);
|
let (mut rsp_tx, rsp_rx) = mpsc::channel(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user