Move StartingBalances into protocol module

This commit is contained in:
Daniel Karzel 2021-01-20 13:29:46 +11:00
parent 41e335fc2d
commit 37f619dbfc
6 changed files with 20 additions and 14 deletions

View File

@ -56,12 +56,6 @@ pub struct SwapAmounts {
pub xmr: monero::Amount, 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). // TODO: Display in XMR and BTC (not picos and sats).
impl Display for SwapAmounts { impl Display for SwapAmounts {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View File

@ -23,9 +23,9 @@ use swap::{
config::Config, config::Config,
database::Database, database::Database,
monero, monero,
protocol::{alice, bob, bob::SwapFactory}, protocol::{alice, bob, bob::SwapFactory, StartingBalances},
trace::init_tracing, trace::init_tracing,
StartingBalances, SwapAmounts, SwapAmounts,
}; };
use tracing::{info, log::LevelFilter}; use tracing::{info, log::LevelFilter};
use uuid::Uuid; use uuid::Uuid;

View File

@ -1,2 +1,8 @@
pub mod alice; pub mod alice;
pub mod bob; pub mod bob;
#[derive(Debug, Clone)]
pub struct StartingBalances {
pub xmr: crate::monero::Amount,
pub btc: bitcoin::Amount,
}

View File

@ -12,7 +12,7 @@ use crate::{
Seed as NetworkSeed, Seed as NetworkSeed,
}, },
protocol::bob, protocol::bob,
StartingBalances, SwapAmounts, SwapAmounts,
}; };
pub use self::{ pub use self::{
@ -24,7 +24,10 @@ pub use self::{
state::*, state::*,
swap::{run, run_until}, 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 libp2p::{core::Multiaddr, identity::Keypair};
use rand::rngs::OsRng; use rand::rngs::OsRng;
use std::{path::PathBuf, sync::Arc}; use std::{path::PathBuf, sync::Arc};

View File

@ -10,7 +10,7 @@ use crate::{
database, monero, network, database, monero, network,
network::peer_tracker::{self, PeerTracker}, network::peer_tracker::{self, PeerTracker},
protocol::{alice, bob}, protocol::{alice, bob},
StartingBalances, SwapAmounts, SwapAmounts,
}; };
pub use self::{ pub use self::{
@ -23,7 +23,10 @@ pub use self::{
state::*, state::*,
swap::{run, run_until}, 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 libp2p::identity::Keypair;
use rand::rngs::OsRng; use rand::rngs::OsRng;
use std::{path::PathBuf, sync::Arc}; use std::{path::PathBuf, sync::Arc};

View File

@ -9,9 +9,9 @@ use swap::{
bitcoin, bitcoin,
config::Config, config::Config,
monero, monero,
protocol::{alice, alice::AliceState, bob, bob::BobState}, protocol::{alice, alice::AliceState, bob, bob::BobState, StartingBalances},
seed::Seed, seed::Seed,
StartingBalances, SwapAmounts, SwapAmounts,
}; };
use tempfile::tempdir; use tempfile::tempdir;
use testcontainers::{clients::Cli, Container}; use testcontainers::{clients::Cli, Container};