From 37f619dbfccb20acde96dee07547700eb413da8c Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Wed, 20 Jan 2021 13:29:46 +1100 Subject: [PATCH] Move StartingBalances into protocol module --- swap/src/lib.rs | 6 ------ swap/src/main.rs | 4 ++-- swap/src/protocol.rs | 6 ++++++ swap/src/protocol/alice.rs | 7 +++++-- swap/src/protocol/bob.rs | 7 +++++-- swap/tests/testutils/mod.rs | 4 ++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/swap/src/lib.rs b/swap/src/lib.rs index 7644da0a..f7020277 100644 --- a/swap/src/lib.rs +++ b/swap/src/lib.rs @@ -56,12 +56,6 @@ pub struct SwapAmounts { pub xmr: monero::Amount, } -#[derive(Debug, Clone)] -pub struct StartingBalances { - pub xmr: monero::Amount, - pub btc: bitcoin::Amount, -} - // TODO: Display in XMR and BTC (not picos and sats). impl Display for SwapAmounts { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/swap/src/main.rs b/swap/src/main.rs index 5c66b952..18beda09 100644 --- a/swap/src/main.rs +++ b/swap/src/main.rs @@ -23,9 +23,9 @@ use swap::{ config::Config, database::Database, monero, - protocol::{alice, bob, bob::SwapFactory}, + protocol::{alice, bob, bob::SwapFactory, StartingBalances}, trace::init_tracing, - StartingBalances, SwapAmounts, + SwapAmounts, }; use tracing::{info, log::LevelFilter}; use uuid::Uuid; diff --git a/swap/src/protocol.rs b/swap/src/protocol.rs index 9de27854..a2e13b79 100644 --- a/swap/src/protocol.rs +++ b/swap/src/protocol.rs @@ -1,2 +1,8 @@ pub mod alice; pub mod bob; + +#[derive(Debug, Clone)] +pub struct StartingBalances { + pub xmr: crate::monero::Amount, + pub btc: bitcoin::Amount, +} diff --git a/swap/src/protocol/alice.rs b/swap/src/protocol/alice.rs index eb0b720a..3b07005b 100644 --- a/swap/src/protocol/alice.rs +++ b/swap/src/protocol/alice.rs @@ -12,7 +12,7 @@ use crate::{ Seed as NetworkSeed, }, protocol::bob, - StartingBalances, SwapAmounts, + SwapAmounts, }; pub use self::{ @@ -24,7 +24,10 @@ pub use self::{ state::*, swap::{run, run_until}, }; -use crate::{config::Config, database::Database, network::transport::build, seed::Seed}; +use crate::{ + config::Config, database::Database, network::transport::build, protocol::StartingBalances, + seed::Seed, +}; use libp2p::{core::Multiaddr, identity::Keypair}; use rand::rngs::OsRng; use std::{path::PathBuf, sync::Arc}; diff --git a/swap/src/protocol/bob.rs b/swap/src/protocol/bob.rs index 4ec70fba..f9ac84a2 100644 --- a/swap/src/protocol/bob.rs +++ b/swap/src/protocol/bob.rs @@ -10,7 +10,7 @@ use crate::{ database, monero, network, network::peer_tracker::{self, PeerTracker}, protocol::{alice, bob}, - StartingBalances, SwapAmounts, + SwapAmounts, }; pub use self::{ @@ -23,7 +23,10 @@ pub use self::{ state::*, swap::{run, run_until}, }; -use crate::{config::Config, database::Database, network::transport::build, seed::Seed}; +use crate::{ + config::Config, database::Database, network::transport::build, protocol::StartingBalances, + seed::Seed, +}; use libp2p::identity::Keypair; use rand::rngs::OsRng; use std::{path::PathBuf, sync::Arc}; diff --git a/swap/tests/testutils/mod.rs b/swap/tests/testutils/mod.rs index 7466faee..021b8bd9 100644 --- a/swap/tests/testutils/mod.rs +++ b/swap/tests/testutils/mod.rs @@ -9,9 +9,9 @@ use swap::{ bitcoin, config::Config, monero, - protocol::{alice, alice::AliceState, bob, bob::BobState}, + protocol::{alice, alice::AliceState, bob, bob::BobState, StartingBalances}, seed::Seed, - StartingBalances, SwapAmounts, + SwapAmounts, }; use tempfile::tempdir; use testcontainers::{clients::Cli, Container};