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.
This commit is contained in:
Daniel Karzel 2021-03-11 17:03:10 +11:00 committed by Thomas Eizinger
parent 82738b111e
commit be52892e65
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
4 changed files with 10 additions and 13 deletions

View File

@ -155,7 +155,7 @@ async fn init_wallets(
config.monero.wallet_rpc_url.clone(), config.monero.wallet_rpc_url.clone(),
MONERO_NETWORK, MONERO_NETWORK,
DEFAULT_WALLET_NAME.to_string(), DEFAULT_WALLET_NAME.to_string(),
execution_params, execution_params.monero_avg_block_time,
); );
// Setup the Monero wallet // Setup the Monero wallet

View File

@ -306,7 +306,7 @@ async fn init_monero_wallet(
monero_wallet_rpc_process.endpoint(), monero_wallet_rpc_process.endpoint(),
monero_network, monero_network,
MONERO_BLOCKCHAIN_MONITORING_WALLET_NAME.to_string(), MONERO_BLOCKCHAIN_MONITORING_WALLET_NAME.to_string(),
execution_params, execution_params.monero_avg_block_time,
); );
monero_wallet.open_or_create().await?; monero_wallet.open_or_create().await?;

View File

@ -1,4 +1,3 @@
use crate::execution_params::ExecutionParams;
use crate::monero::{ use crate::monero::{
Amount, InsufficientFunds, PrivateViewKey, PublicViewKey, TransferProof, TxHash, Amount, InsufficientFunds, PrivateViewKey, PublicViewKey, TransferProof, TxHash,
}; };
@ -20,16 +19,16 @@ pub struct Wallet {
inner: Mutex<wallet::Client>, inner: Mutex<wallet::Client>,
network: Network, network: Network,
name: String, name: String,
exec_params: ExecutionParams, avg_block_time: Duration,
} }
impl Wallet { 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 { Self {
inner: Mutex::new(wallet::Client::new(url)), inner: Mutex::new(wallet::Client::new(url)),
network, network,
name, name,
exec_params, avg_block_time,
} }
} }
@ -37,13 +36,13 @@ impl Wallet {
client: wallet::Client, client: wallet::Client,
network: Network, network: Network,
name: String, name: String,
exec_params: ExecutionParams, avg_block_time: Duration,
) -> Self { ) -> Self {
Self { Self {
inner: Mutex::new(client), inner: Mutex::new(client),
network, network,
name, 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 address = Address::standard(self.network, public_spend_key, public_view_key.into());
let check_interval = tokio::time::interval(min( let check_interval =
self.exec_params.monero_avg_block_time / 10, tokio::time::interval(min(self.avg_block_time / 10, Duration::from_secs(1)));
Duration::from_secs(1),
));
let key = &transfer_proof.tx_key().to_string(); let key = &transfer_proof.tx_key().to_string();
wait_for_confirmations( wait_for_confirmations(

View File

@ -603,7 +603,7 @@ async fn init_test_wallets(
monero.wallet(name).unwrap().client(), monero.wallet(name).unwrap().client(),
monero::Network::default(), monero::Network::default(),
name.to_string(), name.to_string(),
execution_params, execution_params.monero_avg_block_time,
); );
let electrum_rpc_url = { let electrum_rpc_url = {