mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-10-11 21:10:50 -04:00
Make Monero and Bitcoin wallet use a generalized sync interval
We define the sync interval as 1/10th of the blocktime. For the special case of our tests, we however check at max once per second. The tests have a super fast blocktime. As such we shouldn't hammer the nodes with a request every 100ms.
This commit is contained in:
parent
09c41f89c4
commit
ce78075932
3 changed files with 43 additions and 27 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::bitcoin::timelocks::BlockHeight;
|
||||
use crate::bitcoin::{Address, Amount, Transaction};
|
||||
use crate::env::Config;
|
||||
use crate::env;
|
||||
use ::bitcoin::util::psbt::PartiallySignedTransaction;
|
||||
use ::bitcoin::Txid;
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
|
@ -33,7 +33,7 @@ impl Wallet {
|
|||
electrum_rpc_url: Url,
|
||||
wallet_dir: &Path,
|
||||
key: impl DerivableKey<Segwitv0> + Clone,
|
||||
env_config: Config,
|
||||
env_config: env::Config,
|
||||
) -> Result<Self> {
|
||||
// Workaround for https://github.com/bitcoindevkit/rust-electrum-client/issues/47.
|
||||
let config = electrum_client::ConfigBuilder::default().retry(2).build();
|
||||
|
@ -55,11 +55,12 @@ impl Wallet {
|
|||
let electrum = bdk::electrum_client::Client::from_config(electrum_rpc_url.as_str(), config)
|
||||
.map_err(|e| anyhow!("Failed to init electrum rpc client {:?}", e))?;
|
||||
|
||||
let interval = Duration::from_secs(5);
|
||||
|
||||
Ok(Self {
|
||||
wallet: Arc::new(Mutex::new(bdk_wallet)),
|
||||
client: Arc::new(Mutex::new(Client::new(electrum, interval)?)),
|
||||
client: Arc::new(Mutex::new(Client::new(
|
||||
electrum,
|
||||
env_config.bitcoin_sync_interval(),
|
||||
)?)),
|
||||
finality_confirmations: env_config.bitcoin_finality_confirmations,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue