@ -6,7 +6,6 @@ use ::monero::{Address, Network, PrivateKey, PublicKey};
use anyhow ::{ Context , Result } ;
use monero_rpc ::wallet ;
use monero_rpc ::wallet ::{ BlockHeight , CheckTxKey , Client , Refreshed } ;
use std ::cmp ::max ;
use std ::future ::Future ;
use std ::str ::FromStr ;
use std ::time ::Duration ;
@ -20,7 +19,7 @@ pub struct Wallet {
inner : Mutex < wallet ::Client > ,
network : Network ,
name : String ,
avg_block_time : Duration ,
sync_interval : Duration ,
}
impl Wallet {
@ -33,7 +32,7 @@ impl Wallet {
inner : Mutex ::new ( client ) ,
network : env_config . monero_network ,
name ,
avg_block_time: env_config . monero_avg_block_time ,
sync_interval: env_config . monero_sync_interval ( ) ,
}
}
@ -164,7 +163,7 @@ impl Wallet {
let address = Address ::standard ( self . network , public_spend_key , public_view_key . into ( ) ) ;
let check_interval = tokio ::time ::interval ( new_check_interval ( self . avg_block_time ) ) ;
let check_interval = tokio ::time ::interval ( self . sync_interval ) ;
let key = & transfer_proof . tx_key ( ) . to_string ( ) ;
wait_for_confirmations (
@ -223,10 +222,6 @@ impl Wallet {
}
}
fn new_check_interval ( avg_block_time : Duration ) -> Duration {
max ( avg_block_time / 10 , Duration ::from_secs ( 1 ) )
}
async fn wait_for_confirmations < Fut > (
txid : String ,
fetch_tx : impl Fn ( String ) -> Fut ,
@ -346,18 +341,4 @@ mod tests {
assert! ( result . is_ok ( ) )
}
#[ test ]
fn check_interval_is_one_second_if_avg_blocktime_is_one_second ( ) {
let interval = new_check_interval ( Duration ::from_secs ( 1 ) ) ;
assert_eq! ( interval , Duration ::from_secs ( 1 ) )
}
#[ test ]
fn check_interval_is_tenth_of_avg_blocktime ( ) {
let interval = new_check_interval ( Duration ::from_secs ( 100 ) ) ;
assert_eq! ( interval , Duration ::from_secs ( 10 ) )
}
}