From be52892e65bbc090d832959a7ad62b90188466bf Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Thu, 11 Mar 2021 17:03:10 +1100 Subject: [PATCH] Monero wallet should not know about all execution params Instead of passing all execution params in we only make the monero_avg_block_time known to the monero wallet. --- swap/src/bin/asb.rs | 2 +- swap/src/bin/swap.rs | 2 +- swap/src/monero/wallet.rs | 17 +++++++---------- swap/tests/testutils/mod.rs | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/swap/src/bin/asb.rs b/swap/src/bin/asb.rs index 01746d0e..5574d1a5 100644 --- a/swap/src/bin/asb.rs +++ b/swap/src/bin/asb.rs @@ -155,7 +155,7 @@ async fn init_wallets( config.monero.wallet_rpc_url.clone(), MONERO_NETWORK, DEFAULT_WALLET_NAME.to_string(), - execution_params, + execution_params.monero_avg_block_time, ); // Setup the Monero wallet diff --git a/swap/src/bin/swap.rs b/swap/src/bin/swap.rs index c8e64866..30265f74 100644 --- a/swap/src/bin/swap.rs +++ b/swap/src/bin/swap.rs @@ -306,7 +306,7 @@ async fn init_monero_wallet( monero_wallet_rpc_process.endpoint(), monero_network, MONERO_BLOCKCHAIN_MONITORING_WALLET_NAME.to_string(), - execution_params, + execution_params.monero_avg_block_time, ); monero_wallet.open_or_create().await?; diff --git a/swap/src/monero/wallet.rs b/swap/src/monero/wallet.rs index bc762462..441ea1f5 100644 --- a/swap/src/monero/wallet.rs +++ b/swap/src/monero/wallet.rs @@ -1,4 +1,3 @@ -use crate::execution_params::ExecutionParams; use crate::monero::{ Amount, InsufficientFunds, PrivateViewKey, PublicViewKey, TransferProof, TxHash, }; @@ -20,16 +19,16 @@ pub struct Wallet { inner: Mutex, network: Network, name: String, - exec_params: ExecutionParams, + avg_block_time: Duration, } impl Wallet { - pub fn new(url: Url, network: Network, name: String, exec_params: ExecutionParams) -> Self { + pub fn new(url: Url, network: Network, name: String, avg_block_time: Duration) -> Self { Self { inner: Mutex::new(wallet::Client::new(url)), network, name, - exec_params, + avg_block_time, } } @@ -37,13 +36,13 @@ impl Wallet { client: wallet::Client, network: Network, name: String, - exec_params: ExecutionParams, + avg_block_time: Duration, ) -> Self { Self { inner: Mutex::new(client), network, name, - exec_params, + avg_block_time, } } @@ -174,10 +173,8 @@ impl Wallet { let address = Address::standard(self.network, public_spend_key, public_view_key.into()); - let check_interval = tokio::time::interval(min( - self.exec_params.monero_avg_block_time / 10, - Duration::from_secs(1), - )); + let check_interval = + tokio::time::interval(min(self.avg_block_time / 10, Duration::from_secs(1))); let key = &transfer_proof.tx_key().to_string(); wait_for_confirmations( diff --git a/swap/tests/testutils/mod.rs b/swap/tests/testutils/mod.rs index 3b233090..e3d2c744 100644 --- a/swap/tests/testutils/mod.rs +++ b/swap/tests/testutils/mod.rs @@ -603,7 +603,7 @@ async fn init_test_wallets( monero.wallet(name).unwrap().client(), monero::Network::default(), name.to_string(), - execution_params, + execution_params.monero_avg_block_time, ); let electrum_rpc_url = {