From 228da8015b3e674ff187699bea46f8f717295f12 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 4 Feb 2021 16:42:14 +1100 Subject: [PATCH] Move main.rs to cli.rs to prepare for nectar binary --- swap/Cargo.toml | 6 +++++ swap/src/{main.rs => bin/cli.rs} | 40 ++++++++++++-------------------- swap/src/config.rs | 2 ++ swap/src/lib.rs | 3 +++ 4 files changed, 26 insertions(+), 25 deletions(-) rename swap/src/{main.rs => bin/cli.rs} (92%) diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 85609dcc..5cb515da 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -5,6 +5,12 @@ authors = ["CoBloX developers "] edition = "2018" description = "XMR/BTC trustless atomic swaps." +[[bin]] +name = "cli" + +[lib] +name = "swap" + [dependencies] anyhow = "1" async-recursion = "0.3.1" diff --git a/swap/src/main.rs b/swap/src/bin/cli.rs similarity index 92% rename from swap/src/main.rs rename to swap/src/bin/cli.rs index 183011d8..82889b21 100644 --- a/swap/src/main.rs +++ b/swap/src/bin/cli.rs @@ -12,39 +12,29 @@ #![forbid(unsafe_code)] #![allow(non_snake_case)] -use crate::{ +use anyhow::{Context, Result}; +use log::LevelFilter; +use prettytable::{row, Table}; +use std::{path::PathBuf, sync::Arc}; +use structopt::StructOpt; +use swap::{ + bitcoin, cli::{Command, Options, Resume}, + config, config::{ initial_setup, query_user_for_initial_testnet_config, read_config, ConfigNotInitialized, }, + database::Database, + execution_params, execution_params::GetExecutionParams, + fs::{default_config_path, default_data_dir}, + monero, + protocol::{bob, bob::Builder, SwapAmounts}, + trace::init_tracing, }; -use anyhow::{Context, Result}; -use database::Database; -use fs::{default_config_path, default_data_dir}; -use log::LevelFilter; -use prettytable::{row, Table}; -use protocol::{bob, bob::Builder, SwapAmounts}; -use std::{path::PathBuf, sync::Arc}; -use structopt::StructOpt; -use trace::init_tracing; use tracing::info; use uuid::Uuid; -pub mod bitcoin; -pub mod config; -pub mod database; -pub mod execution_params; -pub mod monero; -pub mod network; -pub mod protocol; -pub mod seed; -pub mod trace; - -mod cli; -mod fs; -mod serde_peer_id; - #[macro_use] extern crate prettytable; @@ -66,7 +56,7 @@ async fn main() -> Result<()> { ); let db_path = data_dir.join("database"); - let seed = config::seed::Seed::from_file_or_generate(&data_dir) + let seed = config::Seed::from_file_or_generate(&data_dir) .expect("Could not retrieve/initialize seed") .into(); diff --git a/swap/src/config.rs b/swap/src/config.rs index 11049581..f9f56431 100644 --- a/swap/src/config.rs +++ b/swap/src/config.rs @@ -13,6 +13,8 @@ use url::Url; pub mod seed; +pub use seed::Seed; + const DEFAULT_BITCOIND_TESTNET_URL: &str = "http://127.0.0.1:18332"; const DEFAULT_MONERO_WALLET_RPC_TESTNET_URL: &str = "http://127.0.0.1:38083/json_rpc"; diff --git a/swap/src/lib.rs b/swap/src/lib.rs index 72c81012..f042cddc 100644 --- a/swap/src/lib.rs +++ b/swap/src/lib.rs @@ -17,8 +17,11 @@ )] pub mod bitcoin; +pub mod cli; +pub mod config; pub mod database; pub mod execution_params; +pub mod fs; pub mod monero; pub mod network; pub mod protocol;