Skip to content

Commit c4f1211

Browse files
committed
ref(esplora): Box a large esplora_client::Error
to address `clippy::result_large_err`. Clippy's default large-error- threshold is 128. `esplora_client::Error` currently has size 272.
1 parent 1793ce0 commit c4f1211

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

crates/esplora/src/async_ext.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ use bdk_chain::{
66
local_chain::{self, CheckPoint},
77
BlockId, ConfirmationTimeHeightAnchor, TxGraph,
88
};
9-
use esplora_client::{Error, TxStatus};
9+
use esplora_client::TxStatus;
1010
use futures::{stream::FuturesOrdered, TryStreamExt};
1111

1212
use crate::{anchor_from_status, ASSUME_FINAL_DEPTH};
1313

14+
/// [`esplora_client::Error`]
15+
type Error = Box<esplora_client::Error>;
16+
1417
/// Trait to extend the functionality of [`esplora_client::AsyncClient`].
1518
///
1619
/// Refer to [crate-level documentation] for more.
@@ -29,7 +32,6 @@ pub trait EsploraAsyncExt {
2932
/// [`LocalChain`]: bdk_chain::local_chain::LocalChain
3033
/// [`LocalChain::tip`]: bdk_chain::local_chain::LocalChain::tip
3134
/// [`LocalChain::apply_update`]: bdk_chain::local_chain::LocalChain::apply_update
32-
#[allow(clippy::result_large_err)]
3335
async fn update_local_chain(
3436
&self,
3537
local_tip: CheckPoint,
@@ -44,7 +46,6 @@ pub trait EsploraAsyncExt {
4446
/// The full scan for each keychain stops after a gap of `stop_gap` script pubkeys with no associated
4547
/// transactions. `parallel_requests` specifies the max number of HTTP requests to make in
4648
/// parallel.
47-
#[allow(clippy::result_large_err)]
4849
async fn full_scan<K: Ord + Clone + Send>(
4950
&self,
5051
keychain_spks: BTreeMap<
@@ -67,7 +68,6 @@ pub trait EsploraAsyncExt {
6768
/// may include scripts that have been used, use [`full_scan`] with the keychain.
6869
///
6970
/// [`full_scan`]: EsploraAsyncExt::full_scan
70-
#[allow(clippy::result_large_err)]
7171
async fn sync(
7272
&self,
7373
misc_spks: impl IntoIterator<IntoIter = impl Iterator<Item = ScriptBuf> + Send> + Send,

crates/esplora/src/blocking_ext.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ use bdk_chain::{
77
local_chain::{self, CheckPoint},
88
BlockId, ConfirmationTimeHeightAnchor, TxGraph,
99
};
10-
use esplora_client::{Error, TxStatus};
10+
use esplora_client::TxStatus;
1111

1212
use crate::{anchor_from_status, ASSUME_FINAL_DEPTH};
1313

14+
/// [`esplora_client::Error`]
15+
type Error = Box<esplora_client::Error>;
16+
1417
/// Trait to extend the functionality of [`esplora_client::BlockingClient`].
1518
///
1619
/// Refer to [crate-level documentation] for more.
@@ -27,7 +30,6 @@ pub trait EsploraExt {
2730
/// [`LocalChain`]: bdk_chain::local_chain::LocalChain
2831
/// [`LocalChain::tip`]: bdk_chain::local_chain::LocalChain::tip
2932
/// [`LocalChain::apply_update`]: bdk_chain::local_chain::LocalChain::apply_update
30-
#[allow(clippy::result_large_err)]
3133
fn update_local_chain(
3234
&self,
3335
local_tip: CheckPoint,
@@ -42,7 +44,6 @@ pub trait EsploraExt {
4244
/// The full scan for each keychain stops after a gap of `stop_gap` script pubkeys with no associated
4345
/// transactions. `parallel_requests` specifies the max number of HTTP requests to make in
4446
/// parallel.
45-
#[allow(clippy::result_large_err)]
4647
fn full_scan<K: Ord + Clone>(
4748
&self,
4849
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
@@ -62,7 +63,6 @@ pub trait EsploraExt {
6263
/// may include scripts that have been used, use [`full_scan`] with the keychain.
6364
///
6465
/// [`full_scan`]: EsploraExt::full_scan
65-
#[allow(clippy::result_large_err)]
6666
fn sync(
6767
&self,
6868
misc_spks: impl IntoIterator<Item = ScriptBuf>,
@@ -286,7 +286,12 @@ impl EsploraExt for esplora_client::BlockingClient {
286286
.map(|txid| {
287287
std::thread::spawn({
288288
let client = self.clone();
289-
move || client.get_tx_status(&txid).map(|s| (txid, s))
289+
move || {
290+
client
291+
.get_tx_status(&txid)
292+
.map_err(Box::new)
293+
.map(|s| (txid, s))
294+
}
290295
})
291296
})
292297
.collect::<Vec<JoinHandle<Result<(Txid, TxStatus), Error>>>>();

0 commit comments

Comments
 (0)