Rename config to execution_params

This commit is contained in:
Daniel Karzel 2021-01-29 17:27:50 +11:00
parent 802dc61e7e
commit 89b3775e05
13 changed files with 23 additions and 24 deletions

View File

@ -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 ecdsa_fun::{adaptor::EncryptedSignature, fun::Scalar, Signature};
pub use wallet::Wallet; pub use wallet::Wallet;
use crate::{bitcoin::timelocks::BlockHeight, config::ExecutionParams}; use crate::{bitcoin::timelocks::BlockHeight, execution_params::ExecutionParams};
use ::bitcoin::{ use ::bitcoin::{
hashes::{hex::ToHex, Hash}, hashes::{hex::ToHex, Hash},
secp256k1, secp256k1,

View File

@ -4,7 +4,7 @@ use crate::{
GetBlockHeight, GetNetwork, GetRawTransaction, SignTxLock, Transaction, GetBlockHeight, GetNetwork, GetRawTransaction, SignTxLock, Transaction,
TransactionBlockHeight, TxLock, WaitForTransactionFinality, WatchForRawTransaction, TransactionBlockHeight, TxLock, WaitForTransactionFinality, WatchForRawTransaction,
}, },
config::ExecutionParams, execution_params::ExecutionParams,
}; };
use ::bitcoin::{util::psbt::PartiallySignedTransaction, Txid}; use ::bitcoin::{util::psbt::PartiallySignedTransaction, Txid};
use anyhow::{Context, Result}; use anyhow::{Context, Result};

View File

@ -65,7 +65,7 @@ impl GetExecutionParams for Regtest {
} }
mod mainnet { mod mainnet {
use crate::config::*; use crate::execution_params::*;
// For each step, we are giving Bob 10 minutes to act. // For each step, we are giving Bob 10 minutes to act.
pub static BOB_TIME_TO_ACT: Lazy<Duration> = Lazy::new(|| Duration::from_secs(10 * 60)); pub static BOB_TIME_TO_ACT: Lazy<Duration> = Lazy::new(|| Duration::from_secs(10 * 60));
@ -82,7 +82,7 @@ mod mainnet {
} }
mod testnet { mod testnet {
use crate::config::*; use crate::execution_params::*;
pub static BOB_TIME_TO_ACT: Lazy<Duration> = Lazy::new(|| Duration::from_secs(60 * 60)); pub static BOB_TIME_TO_ACT: Lazy<Duration> = Lazy::new(|| Duration::from_secs(60 * 60));
@ -100,7 +100,7 @@ mod testnet {
} }
mod regtest { mod regtest {
use crate::config::*; use crate::execution_params::*;
// In test, we set a shorter time to fail fast // In test, we set a shorter time to fail fast
pub static BOB_TIME_TO_ACT: Lazy<Duration> = Lazy::new(|| Duration::from_secs(30)); pub static BOB_TIME_TO_ACT: Lazy<Duration> = Lazy::new(|| Duration::from_secs(30));

View File

@ -17,8 +17,8 @@
)] )]
pub mod bitcoin; pub mod bitcoin;
pub mod config;
pub mod database; pub mod database;
pub mod execution_params;
pub mod monero; pub mod monero;
pub mod network; pub mod network;
pub mod protocol; pub mod protocol;

View File

@ -14,10 +14,10 @@
use crate::{ use crate::{
cli::{Command, Options, Resume}, cli::{Command, Options, Resume},
config::GetExecutionParams,
configuration::{ configuration::{
initial_setup, query_user_for_initial_testnet_config, read_config, ConfigNotInitialized, initial_setup, query_user_for_initial_testnet_config, read_config, ConfigNotInitialized,
}, },
execution_params::GetExecutionParams,
}; };
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use database::Database; use database::Database;
@ -32,9 +32,9 @@ use tracing::info;
use uuid::Uuid; use uuid::Uuid;
pub mod bitcoin; pub mod bitcoin;
pub mod config;
pub mod configuration; pub mod configuration;
pub mod database; pub mod database;
pub mod execution_params;
pub mod monero; pub mod monero;
pub mod network; pub mod network;
pub mod protocol; pub mod protocol;
@ -73,7 +73,7 @@ async fn main() -> Result<()> {
// hardcode to testnet/stagenet // hardcode to testnet/stagenet
let bitcoin_network = bitcoin::Network::Testnet; let bitcoin_network = bitcoin::Network::Testnet;
let monero_network = monero::Network::Stagenet; 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 { match opt.cmd {
Command::SellXmr { Command::SellXmr {

View File

@ -10,10 +10,9 @@ pub use self::{
transfer_proof::TransferProof, transfer_proof::TransferProof,
}; };
use crate::{ use crate::{
bitcoin, bitcoin, database,
config::ExecutionParams,
database,
database::Database, database::Database,
execution_params::ExecutionParams,
monero, monero,
network::{ network::{
peer_tracker::{self, PeerTracker}, peer_tracker::{self, PeerTracker},

View File

@ -7,7 +7,7 @@ use crate::{
TransactionBlockHeight, TxCancel, TxLock, TxRefund, WaitForTransactionFinality, TransactionBlockHeight, TxCancel, TxLock, TxRefund, WaitForTransactionFinality,
WatchForRawTransaction, WatchForRawTransaction,
}, },
config::ExecutionParams, execution_params::ExecutionParams,
monero, monero,
monero::Transfer, monero::Transfer,
protocol::{ protocol::{

View File

@ -6,9 +6,9 @@ use crate::{
timelocks::ExpiredTimelocks, TransactionBlockHeight, WaitForTransactionFinality, timelocks::ExpiredTimelocks, TransactionBlockHeight, WaitForTransactionFinality,
WatchForRawTransaction, WatchForRawTransaction,
}, },
config::ExecutionParams,
database, database,
database::Database, database::Database,
execution_params::ExecutionParams,
monero, monero,
monero::CreateWalletForOutput, monero::CreateWalletForOutput,
protocol::{ protocol::{

View File

@ -28,7 +28,7 @@ pub use self::{
swap::{run, run_until}, swap::{run, run_until},
swap_request::*, swap_request::*,
}; };
use crate::{config::ExecutionParams, protocol::alice::TransferProof}; use crate::{execution_params::ExecutionParams, protocol::alice::TransferProof};
mod encrypted_signature; mod encrypted_signature;
pub mod event_loop; pub mod event_loop;

View File

@ -6,7 +6,7 @@ use crate::{
GetBlockHeight, GetNetwork, GetRawTransaction, Transaction, TransactionBlockHeight, GetBlockHeight, GetNetwork, GetRawTransaction, Transaction, TransactionBlockHeight,
TxCancel, Txid, WatchForRawTransaction, TxCancel, Txid, WatchForRawTransaction,
}, },
config::ExecutionParams, execution_params::ExecutionParams,
monero, monero,
monero::{monero_private_key, TransferProof}, monero::{monero_private_key, TransferProof},
protocol::{alice, bob, bob::EncryptedSignature, SwapAmounts}, protocol::{alice, bob, bob::EncryptedSignature, SwapAmounts},

View File

@ -1,8 +1,8 @@
use crate::{ use crate::{
bitcoin, bitcoin,
bitcoin::timelocks::ExpiredTimelocks, bitcoin::timelocks::ExpiredTimelocks,
config::ExecutionParams,
database::{Database, Swap}, database::{Database, Swap},
execution_params::ExecutionParams,
monero, monero,
protocol::{ protocol::{
bob::{self, event_loop::EventLoopHandle, state::*, SwapRequest}, bob::{self, event_loop::EventLoopHandle, state::*, SwapRequest},

View File

@ -1,7 +1,7 @@
pub mod testutils; pub mod testutils;
use swap::{ use swap::{
config, execution_params,
protocol::{alice, alice::AliceState, bob}, protocol::{alice, alice::AliceState, bob},
}; };
use testutils::alice_run_until::is_encsig_learned; 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. /// redeem had the timelock not expired.
#[tokio::test] #[tokio::test]
async fn given_alice_restarts_after_enc_sig_learned_and_bob_already_cancelled_refund_swap() { 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 (alice_swap, alice_join_handle) = ctx.new_swap_as_alice().await;
let (bob_swap, _) = ctx.new_swap_as_bob().await; let (bob_swap, _) = ctx.new_swap_as_bob().await;

View File

@ -8,8 +8,8 @@ use std::{path::PathBuf, sync::Arc};
use swap::{ use swap::{
bitcoin, bitcoin,
bitcoin::Timelock, bitcoin::Timelock,
config, execution_params,
config::{ExecutionParams, GetExecutionParams}, execution_params::{ExecutionParams, GetExecutionParams},
monero, monero,
protocol::{alice, alice::AliceState, bob, bob::BobState, SwapAmounts}, protocol::{alice, alice::AliceState, bob, bob::BobState, SwapAmounts},
seed::Seed, seed::Seed,
@ -518,7 +518,7 @@ impl GetExecutionParams for SlowCancelConfig {
fn get_execution_params() -> ExecutionParams { fn get_execution_params() -> ExecutionParams {
ExecutionParams { ExecutionParams {
bitcoin_cancel_timelock: Timelock::new(180), 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 { fn get_execution_params() -> ExecutionParams {
ExecutionParams { ExecutionParams {
bitcoin_cancel_timelock: Timelock::new(1), 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 { ExecutionParams {
bitcoin_cancel_timelock: Timelock::new(1), bitcoin_cancel_timelock: Timelock::new(1),
bitcoin_punish_timelock: Timelock::new(1), bitcoin_punish_timelock: Timelock::new(1),
..config::Regtest::get_execution_params() ..execution_params::Regtest::get_execution_params()
} }
} }
} }