mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Add error logging to request_response
This commit is contained in:
parent
b8ab4b4eee
commit
119f2a7c54
@ -80,6 +80,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
},
|
},
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
|
tracing::debug!("amounts: Request from Bob received");
|
||||||
if let BobToAlice::AmountsFromBtc(btc) = request {
|
if let BobToAlice::AmountsFromBtc(btc) = request {
|
||||||
self.events.push_back(OutEvent::Btc { btc, channel })
|
self.events.push_back(OutEvent::Btc { btc, channel })
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,9 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
|
|||||||
},
|
},
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
|
tracing::debug!("message0: Request from Bob received");
|
||||||
if let BobToAlice::Message0(msg) = request {
|
if let BobToAlice::Message0(msg) = request {
|
||||||
info!("Got Alice's first message");
|
info!("Got Bob'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?"),
|
||||||
Some(state) => {
|
Some(state) => {
|
||||||
|
@ -6,6 +6,7 @@ use libp2p::{
|
|||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{fmt::Debug, io};
|
use std::{fmt::Debug, io};
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::SwapAmounts;
|
use crate::SwapAmounts;
|
||||||
use xmr_btc::{alice, bob, monero};
|
use xmr_btc::{alice, bob, monero};
|
||||||
@ -65,12 +66,15 @@ impl RequestResponseCodec for Codec {
|
|||||||
where
|
where
|
||||||
T: AsyncRead + Unpin + Send,
|
T: AsyncRead + Unpin + Send,
|
||||||
{
|
{
|
||||||
|
debug!("enter read_request");
|
||||||
let message = upgrade::read_one(io, BUF_SIZE)
|
let message = upgrade::read_one(io, BUF_SIZE)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
||||||
let mut de = serde_cbor::Deserializer::from_slice(&message);
|
let mut de = serde_cbor::Deserializer::from_slice(&message);
|
||||||
let msg = BobToAlice::deserialize(&mut de)
|
let msg = BobToAlice::deserialize(&mut de).map_err(|e| {
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
tracing::debug!("serde read_request error: {:?}", e);
|
||||||
|
io::Error::new(io::ErrorKind::Other, e)
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok(msg)
|
Ok(msg)
|
||||||
}
|
}
|
||||||
@ -83,12 +87,15 @@ impl RequestResponseCodec for Codec {
|
|||||||
where
|
where
|
||||||
T: AsyncRead + Unpin + Send,
|
T: AsyncRead + Unpin + Send,
|
||||||
{
|
{
|
||||||
|
debug!("enter read_response");
|
||||||
let message = upgrade::read_one(io, BUF_SIZE)
|
let message = upgrade::read_one(io, BUF_SIZE)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
||||||
let mut de = serde_cbor::Deserializer::from_slice(&message);
|
let mut de = serde_cbor::Deserializer::from_slice(&message);
|
||||||
let msg = AliceToBob::deserialize(&mut de)
|
let msg = AliceToBob::deserialize(&mut de).map_err(|e| {
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
tracing::debug!("serde read_response error: {:?}", e);
|
||||||
|
io::Error::new(io::ErrorKind::InvalidData, e)
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok(msg)
|
Ok(msg)
|
||||||
}
|
}
|
||||||
@ -102,8 +109,9 @@ impl RequestResponseCodec for Codec {
|
|||||||
where
|
where
|
||||||
T: AsyncWrite + Unpin + Send,
|
T: AsyncWrite + Unpin + Send,
|
||||||
{
|
{
|
||||||
|
debug!("enter write_request");
|
||||||
let bytes = serde_cbor::to_vec(&req).map_err(|e| {
|
let bytes = serde_cbor::to_vec(&req).map_err(|e| {
|
||||||
tracing::debug!("yes Lucas we are actually here");
|
tracing::debug!("serde write_request error: {:?}", e);
|
||||||
io::Error::new(io::ErrorKind::InvalidData, e)
|
io::Error::new(io::ErrorKind::InvalidData, e)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@ -121,8 +129,11 @@ impl RequestResponseCodec for Codec {
|
|||||||
where
|
where
|
||||||
T: AsyncWrite + Unpin + Send,
|
T: AsyncWrite + Unpin + Send,
|
||||||
{
|
{
|
||||||
let bytes =
|
debug!("enter write_response");
|
||||||
serde_cbor::to_vec(&res).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
|
let bytes = serde_cbor::to_vec(&res).map_err(|e| {
|
||||||
|
tracing::debug!("serde write_reponse error: {:?}", e);
|
||||||
|
io::Error::new(io::ErrorKind::InvalidData, e)
|
||||||
|
})?;
|
||||||
upgrade::write_one(io, &bytes).await?;
|
upgrade::write_one(io, &bytes).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user