From 89b3775e05f796d1c270a7c8a91589f56f1ad563 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Fri, 29 Jan 2021 17:27:50 +1100 Subject: [PATCH] Rename config to execution_params --- swap/src/bitcoin.rs | 2 +- swap/src/bitcoin/wallet.rs | 2 +- swap/src/{config.rs => execution_params.rs} | 6 +++--- swap/src/lib.rs | 2 +- swap/src/main.rs | 6 +++--- swap/src/protocol/alice.rs | 5 ++--- swap/src/protocol/alice/steps.rs | 2 +- swap/src/protocol/alice/swap.rs | 2 +- swap/src/protocol/bob.rs | 2 +- swap/src/protocol/bob/state.rs | 2 +- swap/src/protocol/bob/swap.rs | 2 +- swap/tests/refund_restart_alice_cancelled.rs | 4 ++-- swap/tests/testutils/mod.rs | 10 +++++----- 13 files changed, 23 insertions(+), 24 deletions(-) rename swap/src/{config.rs => execution_params.rs} (97%) diff --git a/swap/src/bitcoin.rs b/swap/src/bitcoin.rs index 95bcf036..b55e917c 100644 --- a/swap/src/bitcoin.rs +++ b/swap/src/bitcoin.rs @@ -10,7 +10,7 @@ pub use ::bitcoin::{util::amount::Amount, Address, Network, Transaction, Txid}; pub use ecdsa_fun::{adaptor::EncryptedSignature, fun::Scalar, Signature}; pub use wallet::Wallet; -use crate::{bitcoin::timelocks::BlockHeight, config::ExecutionParams}; +use crate::{bitcoin::timelocks::BlockHeight, execution_params::ExecutionParams}; use ::bitcoin::{ hashes::{hex::ToHex, Hash}, secp256k1, diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index 38271436..793394ae 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -4,7 +4,7 @@ use crate::{ GetBlockHeight, GetNetwork, GetRawTransaction, SignTxLock, Transaction, TransactionBlockHeight, TxLock, WaitForTransactionFinality, WatchForRawTransaction, }, - config::ExecutionParams, + execution_params::ExecutionParams, }; use ::bitcoin::{util::psbt::PartiallySignedTransaction, Txid}; use anyhow::{Context, Result}; diff --git a/swap/src/config.rs b/swap/src/execution_params.rs similarity index 97% rename from swap/src/config.rs rename to swap/src/execution_params.rs index d73f8683..836a580d 100644 --- a/swap/src/config.rs +++ b/swap/src/execution_params.rs @@ -65,7 +65,7 @@ impl GetExecutionParams for Regtest { } mod mainnet { - use crate::config::*; + use crate::execution_params::*; // For each step, we are giving Bob 10 minutes to act. pub static BOB_TIME_TO_ACT: Lazy = Lazy::new(|| Duration::from_secs(10 * 60)); @@ -82,7 +82,7 @@ mod mainnet { } mod testnet { - use crate::config::*; + use crate::execution_params::*; pub static BOB_TIME_TO_ACT: Lazy = Lazy::new(|| Duration::from_secs(60 * 60)); @@ -100,7 +100,7 @@ mod testnet { } mod regtest { - use crate::config::*; + use crate::execution_params::*; // In test, we set a shorter time to fail fast pub static BOB_TIME_TO_ACT: Lazy = Lazy::new(|| Duration::from_secs(30)); diff --git a/swap/src/lib.rs b/swap/src/lib.rs index ce734445..72c81012 100644 --- a/swap/src/lib.rs +++ b/swap/src/lib.rs @@ -17,8 +17,8 @@ )] pub mod bitcoin; -pub mod config; pub mod database; +pub mod execution_params; pub mod monero; pub mod network; pub mod protocol; diff --git a/swap/src/main.rs b/swap/src/main.rs index 2d62d1e9..d404c415 100644 --- a/swap/src/main.rs +++ b/swap/src/main.rs @@ -14,10 +14,10 @@ use crate::{ cli::{Command, Options, Resume}, - config::GetExecutionParams, configuration::{ initial_setup, query_user_for_initial_testnet_config, read_config, ConfigNotInitialized, }, + execution_params::GetExecutionParams, }; use anyhow::{Context, Result}; use database::Database; @@ -32,9 +32,9 @@ use tracing::info; use uuid::Uuid; pub mod bitcoin; -pub mod config; pub mod configuration; pub mod database; +pub mod execution_params; pub mod monero; pub mod network; pub mod protocol; @@ -73,7 +73,7 @@ async fn main() -> Result<()> { // hardcode to testnet/stagenet let bitcoin_network = bitcoin::Network::Testnet; let monero_network = monero::Network::Stagenet; - let execution_params = config::Testnet::get_execution_params(); + let execution_params = execution_params::Testnet::get_execution_params(); match opt.cmd { Command::SellXmr { diff --git a/swap/src/protocol/alice.rs b/swap/src/protocol/alice.rs index c1bbdfdd..20bf002f 100644 --- a/swap/src/protocol/alice.rs +++ b/swap/src/protocol/alice.rs @@ -10,10 +10,9 @@ pub use self::{ transfer_proof::TransferProof, }; use crate::{ - bitcoin, - config::ExecutionParams, - database, + bitcoin, database, database::Database, + execution_params::ExecutionParams, monero, network::{ peer_tracker::{self, PeerTracker}, diff --git a/swap/src/protocol/alice/steps.rs b/swap/src/protocol/alice/steps.rs index b3850ca3..86b96b5c 100644 --- a/swap/src/protocol/alice/steps.rs +++ b/swap/src/protocol/alice/steps.rs @@ -7,7 +7,7 @@ use crate::{ TransactionBlockHeight, TxCancel, TxLock, TxRefund, WaitForTransactionFinality, WatchForRawTransaction, }, - config::ExecutionParams, + execution_params::ExecutionParams, monero, monero::Transfer, protocol::{ diff --git a/swap/src/protocol/alice/swap.rs b/swap/src/protocol/alice/swap.rs index 641aac72..0cbcac28 100644 --- a/swap/src/protocol/alice/swap.rs +++ b/swap/src/protocol/alice/swap.rs @@ -6,9 +6,9 @@ use crate::{ timelocks::ExpiredTimelocks, TransactionBlockHeight, WaitForTransactionFinality, WatchForRawTransaction, }, - config::ExecutionParams, database, database::Database, + execution_params::ExecutionParams, monero, monero::CreateWalletForOutput, protocol::{ diff --git a/swap/src/protocol/bob.rs b/swap/src/protocol/bob.rs index 16d31568..810af8c2 100644 --- a/swap/src/protocol/bob.rs +++ b/swap/src/protocol/bob.rs @@ -28,7 +28,7 @@ pub use self::{ swap::{run, run_until}, swap_request::*, }; -use crate::{config::ExecutionParams, protocol::alice::TransferProof}; +use crate::{execution_params::ExecutionParams, protocol::alice::TransferProof}; mod encrypted_signature; pub mod event_loop; diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index 9b453f6e..f727291a 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -6,7 +6,7 @@ use crate::{ GetBlockHeight, GetNetwork, GetRawTransaction, Transaction, TransactionBlockHeight, TxCancel, Txid, WatchForRawTransaction, }, - config::ExecutionParams, + execution_params::ExecutionParams, monero, monero::{monero_private_key, TransferProof}, protocol::{alice, bob, bob::EncryptedSignature, SwapAmounts}, diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 8bbabe6d..ced72266 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -1,8 +1,8 @@ use crate::{ bitcoin, bitcoin::timelocks::ExpiredTimelocks, - config::ExecutionParams, database::{Database, Swap}, + execution_params::ExecutionParams, monero, protocol::{ bob::{self, event_loop::EventLoopHandle, state::*, SwapRequest}, diff --git a/swap/tests/refund_restart_alice_cancelled.rs b/swap/tests/refund_restart_alice_cancelled.rs index 7c47c171..116c1fd4 100644 --- a/swap/tests/refund_restart_alice_cancelled.rs +++ b/swap/tests/refund_restart_alice_cancelled.rs @@ -1,7 +1,7 @@ pub mod testutils; use swap::{ - config, + execution_params, protocol::{alice, alice::AliceState, bob}, }; use testutils::alice_run_until::is_encsig_learned; @@ -11,7 +11,7 @@ use testutils::alice_run_until::is_encsig_learned; /// redeem had the timelock not expired. #[tokio::test] async fn given_alice_restarts_after_enc_sig_learned_and_bob_already_cancelled_refund_swap() { - testutils::setup_test(config::Regtest, |mut ctx| async move { + testutils::setup_test(execution_params::Regtest, |mut ctx| async move { let (alice_swap, alice_join_handle) = ctx.new_swap_as_alice().await; let (bob_swap, _) = ctx.new_swap_as_bob().await; diff --git a/swap/tests/testutils/mod.rs b/swap/tests/testutils/mod.rs index 9ddccbe1..1d435958 100644 --- a/swap/tests/testutils/mod.rs +++ b/swap/tests/testutils/mod.rs @@ -8,8 +8,8 @@ use std::{path::PathBuf, sync::Arc}; use swap::{ bitcoin, bitcoin::Timelock, - config, - config::{ExecutionParams, GetExecutionParams}, + execution_params, + execution_params::{ExecutionParams, GetExecutionParams}, monero, protocol::{alice, alice::AliceState, bob, bob::BobState, SwapAmounts}, seed::Seed, @@ -518,7 +518,7 @@ impl GetExecutionParams for SlowCancelConfig { fn get_execution_params() -> ExecutionParams { ExecutionParams { bitcoin_cancel_timelock: Timelock::new(180), - ..config::Regtest::get_execution_params() + ..execution_params::Regtest::get_execution_params() } } } @@ -529,7 +529,7 @@ impl GetExecutionParams for FastCancelConfig { fn get_execution_params() -> ExecutionParams { ExecutionParams { bitcoin_cancel_timelock: Timelock::new(1), - ..config::Regtest::get_execution_params() + ..execution_params::Regtest::get_execution_params() } } } @@ -541,7 +541,7 @@ impl GetExecutionParams for FastPunishConfig { ExecutionParams { bitcoin_cancel_timelock: Timelock::new(1), bitcoin_punish_timelock: Timelock::new(1), - ..config::Regtest::get_execution_params() + ..execution_params::Regtest::get_execution_params() } } }