Instantiate electrum client with custom config with 2 retries

The default number of retries is 1. Unfortunately, the way this config
value is interpreted doesn't actually lead to a retry. We have to set
it to 2 to actually make it retry.

See https://github.com/bitcoindevkit/rust-electrum-client/issues/47.
pull/178/head
Thomas Eizinger 3 years ago committed by rishflab
parent 180e778df9
commit a51194b9fa

@ -12,7 +12,7 @@ use async_trait::async_trait;
use backoff::{backoff::Constant as ConstantBackoff, tokio::retry};
use bdk::{
blockchain::{noop_progress, Blockchain, ElectrumBlockchain},
electrum_client::{Client, ElectrumApi},
electrum_client::{self, Client, ElectrumApi},
keys::GeneratableDefaultOptions,
FeeRate,
};
@ -45,7 +45,10 @@ impl Wallet {
network: bitcoin::Network,
waller_dir: &Path,
) -> Result<Self> {
let client = Client::new(electrum_rpc_url.as_str())
// Workaround for https://github.com/bitcoindevkit/rust-electrum-client/issues/47.
let config = electrum_client::ConfigBuilder::default().retry(2).build();
let client = Client::from_config(electrum_rpc_url.as_str(), config)
.map_err(|e| anyhow!("Failed to init electrum rpc client: {:?}", e))?;
let db = bdk::sled::open(waller_dir)?.open_tree(SLED_TREE_NAME)?;

Loading…
Cancel
Save