From 519d1a5701947999c9dd94cac47aa6f30fde7aea Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Fri, 19 Feb 2021 10:25:59 +1100 Subject: [PATCH] Log rate and amounts for Alice when doing execution setup --- swap/src/asb/amounts.rs | 8 +++++++- swap/src/protocol/alice/behaviour.rs | 1 - swap/src/protocol/alice/event_loop.rs | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/swap/src/asb/amounts.rs b/swap/src/asb/amounts.rs index fc43ffaf..228672d9 100644 --- a/swap/src/asb/amounts.rs +++ b/swap/src/asb/amounts.rs @@ -1,7 +1,7 @@ use crate::{bitcoin, monero}; use anyhow::{anyhow, Result}; use rust_decimal::{prelude::ToPrimitive, Decimal}; -use std::fmt::Debug; +use std::fmt::{Debug, Display, Formatter}; /// Prices at which 1 XMR will be traded, in BTC (XMR/BTC pair) /// The `ask` represents the minimum price in BTC for which we are willing to @@ -48,6 +48,12 @@ impl Rate { } } +impl Display for Rate { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.ask) + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/swap/src/protocol/alice/behaviour.rs b/swap/src/protocol/alice/behaviour.rs index ea5a814f..eef2350c 100644 --- a/swap/src/protocol/alice/behaviour.rs +++ b/swap/src/protocol/alice/behaviour.rs @@ -127,7 +127,6 @@ impl Behaviour { pub fn start_execution_setup(&mut self, bob_peer_id: PeerId, state0: State0) { self.execution_setup.run(bob_peer_id, state0); - info!("Start execution setup with {}", bob_peer_id); } /// Send Transfer Proof to Bob. diff --git a/swap/src/protocol/alice/event_loop.rs b/swap/src/protocol/alice/event_loop.rs index 2cc498bf..b0a03d71 100644 --- a/swap/src/protocol/alice/event_loop.rs +++ b/swap/src/protocol/alice/event_loop.rs @@ -22,7 +22,7 @@ use libp2p::{ use rand::rngs::OsRng; use std::sync::Arc; use tokio::sync::{broadcast, mpsc, mpsc::error::SendError}; -use tracing::{debug, error, trace}; +use tracing::{debug, error, info, trace}; use uuid::Uuid; #[allow(missing_debug_implementations)] @@ -229,6 +229,11 @@ where ) .await?; + info!( + "Starting execution setup to sell {} for {} (rate of {}) with {}", + xmr_amount, btc_amount, rate, bob_peer_id + ); + self.swarm.start_execution_setup(bob_peer_id, state0); // Continues once the execution setup protocol is done Ok(())