]> Untitled Git - bdk/commitdiff
ref(esplora): `Box` a large `esplora_client::Error`
authorvmammal <valuedmammal@protonmail.com>
Sun, 29 Oct 2023 05:02:31 +0000 (01:02 -0400)
committervmammal <valuedmammal@protonmail.com>
Wed, 31 Jan 2024 16:50:41 +0000 (11:50 -0500)
to address `clippy::result_large_err`. Clippy's default large-error-
threshold is 128. `esplora_client::Error` currently has size 272.

crates/esplora/src/async_ext.rs
crates/esplora/src/blocking_ext.rs

index 8e697a2a9ae5d4fb25090398d81ad7909d8a7638..fddedf3e25aef185f2461acbc631d986117dd847 100644 (file)
@@ -6,11 +6,14 @@ use bdk_chain::{
     local_chain::{self, CheckPoint},
     BlockId, ConfirmationTimeHeightAnchor, TxGraph,
 };
-use esplora_client::{Error, TxStatus};
+use esplora_client::TxStatus;
 use futures::{stream::FuturesOrdered, TryStreamExt};
 
 use crate::anchor_from_status;
 
+/// [`esplora_client::Error`]
+type Error = Box<esplora_client::Error>;
+
 /// Trait to extend the functionality of [`esplora_client::AsyncClient`].
 ///
 /// Refer to [crate-level documentation] for more.
@@ -35,7 +38,6 @@ pub trait EsploraAsyncExt {
     /// [`LocalChain`]: bdk_chain::local_chain::LocalChain
     /// [`LocalChain::tip`]: bdk_chain::local_chain::LocalChain::tip
     /// [`LocalChain::apply_update`]: bdk_chain::local_chain::LocalChain::apply_update
-    #[allow(clippy::result_large_err)]
     async fn update_local_chain(
         &self,
         local_tip: CheckPoint,
@@ -50,7 +52,6 @@ pub trait EsploraAsyncExt {
     /// The full scan for each keychain stops after a gap of `stop_gap` script pubkeys with no associated
     /// transactions. `parallel_requests` specifies the max number of HTTP requests to make in
     /// parallel.
-    #[allow(clippy::result_large_err)]
     async fn full_scan<K: Ord + Clone + Send>(
         &self,
         keychain_spks: BTreeMap<
@@ -73,7 +74,6 @@ pub trait EsploraAsyncExt {
     /// may include scripts that have been used, use [`full_scan`] with the keychain.
     ///
     /// [`full_scan`]: EsploraAsyncExt::full_scan
-    #[allow(clippy::result_large_err)]
     async fn sync(
         &self,
         misc_spks: impl IntoIterator<IntoIter = impl Iterator<Item = ScriptBuf> + Send> + Send,
index a7ee290b00c2a2a0c56e643528f8a130d4febc92..8e53ce2184cf5040d41c2a09aba9b9b28a7298bc 100644 (file)
@@ -7,10 +7,13 @@ use bdk_chain::{
     local_chain::{self, CheckPoint},
     BlockId, ConfirmationTimeHeightAnchor, TxGraph,
 };
-use esplora_client::{Error, TxStatus};
+use esplora_client::TxStatus;
 
 use crate::anchor_from_status;
 
+/// [`esplora_client::Error`]
+type Error = Box<esplora_client::Error>;
+
 /// Trait to extend the functionality of [`esplora_client::BlockingClient`].
 ///
 /// Refer to [crate-level documentation] for more.
@@ -33,7 +36,6 @@ pub trait EsploraExt {
     /// [`LocalChain`]: bdk_chain::local_chain::LocalChain
     /// [`LocalChain::tip`]: bdk_chain::local_chain::LocalChain::tip
     /// [`LocalChain::apply_update`]: bdk_chain::local_chain::LocalChain::apply_update
-    #[allow(clippy::result_large_err)]
     fn update_local_chain(
         &self,
         local_tip: CheckPoint,
@@ -48,7 +50,6 @@ pub trait EsploraExt {
     /// The full scan for each keychain stops after a gap of `stop_gap` script pubkeys with no associated
     /// transactions. `parallel_requests` specifies the max number of HTTP requests to make in
     /// parallel.
-    #[allow(clippy::result_large_err)]
     fn full_scan<K: Ord + Clone>(
         &self,
         keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
@@ -68,7 +69,6 @@ pub trait EsploraExt {
     /// may include scripts that have been used, use [`full_scan`] with the keychain.
     ///
     /// [`full_scan`]: EsploraExt::full_scan
-    #[allow(clippy::result_large_err)]
     fn sync(
         &self,
         misc_spks: impl IntoIterator<Item = ScriptBuf>,
@@ -247,7 +247,12 @@ impl EsploraExt for esplora_client::BlockingClient {
                 .map(|txid| {
                     std::thread::spawn({
                         let client = self.clone();
-                        move || client.get_tx_status(&txid).map(|s| (txid, s))
+                        move || {
+                            client
+                                .get_tx_status(&txid)
+                                .map_err(Box::new)
+                                .map(|s| (txid, s))
+                        }
                     })
                 })
                 .collect::<Vec<JoinHandle<Result<(Txid, TxStatus), Error>>>>();