Remove dependency of main.rs on lib.rs

This commit is contained in:
Franck Royer 2021-01-21 14:00:37 +11:00
parent f2a25ee49b
commit 10eeecfe54
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
3 changed files with 20 additions and 20 deletions

View File

@ -1,6 +1,5 @@
#![warn( #![warn(
unused_extern_crates, unused_extern_crates,
missing_debug_implementations,
missing_copy_implementations, missing_copy_implementations,
rust_2018_idioms, rust_2018_idioms,
clippy::cast_possible_truncation, clippy::cast_possible_truncation,
@ -13,26 +12,28 @@
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
use std::sync::Arc; use crate::cli::{Command, Options, Resume};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use config::Config;
use database::Database;
use prettytable::{row, Table}; use prettytable::{row, Table};
use protocol::{alice, bob, bob::Builder, SwapAmounts};
use std::sync::Arc;
use structopt::StructOpt; use structopt::StructOpt;
use trace::init_tracing;
use tracing::{info, log::LevelFilter}; use tracing::{info, log::LevelFilter};
use uuid::Uuid; use uuid::Uuid;
use swap::{ pub mod bitcoin;
bitcoin,
config::Config,
database::Database,
monero,
protocol::{alice, bob, bob::Builder, SwapAmounts},
trace::init_tracing,
};
use crate::cli::{Command, Options, Resume};
mod cli; mod cli;
pub mod config;
pub mod database;
mod fs;
pub mod monero;
pub mod network;
pub mod protocol;
pub mod seed;
pub mod trace;
#[macro_use] #[macro_use]
extern crate prettytable; extern crate prettytable;
@ -51,7 +52,7 @@ async fn main() -> Result<()> {
let data_dir = std::path::Path::new(opt.data_dir.as_str()).to_path_buf(); let data_dir = std::path::Path::new(opt.data_dir.as_str()).to_path_buf();
let db_path = data_dir.join("database"); let db_path = data_dir.join("database");
let seed = swap::config::seed::Seed::from_file_or_generate(&data_dir) let seed = config::seed::Seed::from_file_or_generate(&data_dir)
.expect("Could not retrieve/initialize seed") .expect("Could not retrieve/initialize seed")
.into(); .into();
@ -229,10 +230,9 @@ async fn setup_wallets(
bitcoin_wallet_name: &str, bitcoin_wallet_name: &str,
monero_wallet_rpc_url: url::Url, monero_wallet_rpc_url: url::Url,
config: Config, config: Config,
) -> Result<(swap::bitcoin::Wallet, swap::monero::Wallet)> { ) -> Result<(bitcoin::Wallet, monero::Wallet)> {
let bitcoin_wallet = let bitcoin_wallet =
swap::bitcoin::Wallet::new(bitcoin_wallet_name, bitcoind_url, config.bitcoin_network) bitcoin::Wallet::new(bitcoin_wallet_name, bitcoind_url, config.bitcoin_network).await?;
.await?;
let bitcoin_balance = bitcoin_wallet.balance().await?; let bitcoin_balance = bitcoin_wallet.balance().await?;
info!( info!(
"Connection to Bitcoin wallet succeeded, balance: {}", "Connection to Bitcoin wallet succeeded, balance: {}",

View File

@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
pub mod alice; pub mod alice;
pub mod bob; pub mod bob;
#[derive(Debug, Clone)] #[derive(Debug, Copy, Clone)]
pub struct StartingBalances { pub struct StartingBalances {
pub xmr: crate::monero::Amount, pub xmr: crate::monero::Amount,
pub btc: bitcoin::Amount, pub btc: bitcoin::Amount,

View File

@ -19,7 +19,7 @@ use std::{
}; };
use tracing::{debug, error}; use tracing::{debug, error};
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub struct SwapRequest { pub struct SwapRequest {
#[serde(with = "::bitcoin::util::amount::serde::as_sat")] #[serde(with = "::bitcoin::util::amount::serde::as_sat")]
pub btc_amount: bitcoin::Amount, pub btc_amount: bitcoin::Amount,