]> Untitled Git - bdk/commitdiff
refactor: rename methods in EsploraExt and EsploraExtAsync
authorVladimir Fomene <vladimirfomene@gmail.com>
Wed, 9 Aug 2023 09:42:04 +0000 (12:42 +0300)
committerVladimir Fomene <vladimirfomene@gmail.com>
Tue, 12 Sep 2023 13:38:49 +0000 (16:38 +0300)
crates/esplora/src/async_ext.rs
crates/esplora/src/blocking_ext.rs
example-crates/example_esplora/src/main.rs
example-crates/wallet_esplora_async/src/main.rs
example-crates/wallet_esplora_blocking/src/main.rs

index 389022f0cfc437f7323a10df2afeec015def236e..c6e2b05c482e1632c9191a726efb08629505ea7f 100644 (file)
@@ -48,7 +48,7 @@ pub trait EsploraAsyncExt {
     /// transactions. `parallel_requests` specifies the max number of HTTP requests to make in
     /// parallel.
     #[allow(clippy::result_large_err)]
-    async fn update_tx_graph<K: Ord + Clone + Send>(
+    async fn scan_txs_with_keychains<K: Ord + Clone + Send>(
         &self,
         keychain_spks: BTreeMap<
             K,
@@ -60,18 +60,18 @@ pub trait EsploraAsyncExt {
         parallel_requests: usize,
     ) -> Result<(TxGraph<ConfirmationTimeAnchor>, BTreeMap<K, u32>), Error>;
 
-    /// Convenience method to call [`update_tx_graph`] without requiring a keychain.
+    /// Convenience method to call [`scan_txs_with_keychains`] without requiring a keychain.
     ///
-    /// [`update_tx_graph`]: EsploraAsyncExt::update_tx_graph
+    /// [`scan_txs_with_keychains`]: EsploraAsyncExt::scan_txs_with_keychains
     #[allow(clippy::result_large_err)]
-    async fn update_tx_graph_without_keychain(
+    async fn scan_txs(
         &self,
         misc_spks: impl IntoIterator<IntoIter = impl Iterator<Item = ScriptBuf> + Send> + Send,
         txids: impl IntoIterator<IntoIter = impl Iterator<Item = Txid> + Send> + Send,
         outpoints: impl IntoIterator<IntoIter = impl Iterator<Item = OutPoint> + Send> + Send,
         parallel_requests: usize,
     ) -> Result<TxGraph<ConfirmationTimeAnchor>, Error> {
-        self.update_tx_graph(
+        self.scan_txs_with_keychains(
             [(
                 (),
                 misc_spks
@@ -201,7 +201,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
         })
     }
 
-    async fn update_tx_graph<K: Ord + Clone + Send>(
+    async fn scan_txs_with_keychains<K: Ord + Clone + Send>(
         &self,
         keychain_spks: BTreeMap<
             K,
index 6d42fe015a34f69a2aff5ce56874015de4fdb38d..218e9c7f99b74211735549c1550d4dd4d0398730 100644 (file)
@@ -46,7 +46,7 @@ pub trait EsploraExt {
     /// transactions. `parallel_requests` specifies the max number of HTTP requests to make in
     /// parallel.
     #[allow(clippy::result_large_err)]
-    fn update_tx_graph<K: Ord + Clone>(
+    fn scan_txs_with_keychains<K: Ord + Clone>(
         &self,
         keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
         txids: impl IntoIterator<Item = Txid>,
@@ -55,18 +55,18 @@ pub trait EsploraExt {
         parallel_requests: usize,
     ) -> Result<(TxGraph<ConfirmationTimeAnchor>, BTreeMap<K, u32>), Error>;
 
-    /// Convenience method to call [`update_tx_graph`] without requiring a keychain.
+    /// Convenience method to call [`scan_txs_with_keychains`] without requiring a keychain.
     ///
-    /// [`update_tx_graph`]: EsploraExt::update_tx_graph
+    /// [`scan_txs_with_keychains`]: EsploraExt::scan_txs_with_keychains
     #[allow(clippy::result_large_err)]
-    fn update_tx_graph_without_keychain(
+    fn scan_txs(
         &self,
         misc_spks: impl IntoIterator<Item = ScriptBuf>,
         txids: impl IntoIterator<Item = Txid>,
         outpoints: impl IntoIterator<Item = OutPoint>,
         parallel_requests: usize,
     ) -> Result<TxGraph<ConfirmationTimeAnchor>, Error> {
-        self.update_tx_graph(
+        self.scan_txs_with_keychains(
             [(
                 (),
                 misc_spks
@@ -192,7 +192,7 @@ impl EsploraExt for esplora_client::BlockingClient {
         })
     }
 
-    fn update_tx_graph<K: Ord + Clone>(
+    fn scan_txs_with_keychains<K: Ord + Clone>(
         &self,
         keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
         txids: impl IntoIterator<Item = Txid>,
index f33125be8e6fc402fe839d6dc91645a70d1a0b22..1aff0db25748a06e4f48c87bc07187a7c80e47d9 100644 (file)
@@ -154,7 +154,7 @@ fn main() -> anyhow::Result<()> {
             // represents the last active spk derivation indices of keychains
             // (`keychain_indices_update`).
             let (graph_update, last_active_indices) = client
-                .update_tx_graph(
+                .scan_txs_with_keychains(
                     keychain_spks,
                     core::iter::empty(),
                     core::iter::empty(),
@@ -276,12 +276,8 @@ fn main() -> anyhow::Result<()> {
                 }
             }
 
-            let graph_update = client.update_tx_graph_without_keychain(
-                spks,
-                txids,
-                outpoints,
-                scan_options.parallel_requests,
-            )?;
+            let graph_update =
+                client.scan_txs(spks, txids, outpoints, scan_options.parallel_requests)?;
 
             graph.lock().unwrap().apply_update(graph_update)
         }
index 343a09763fd5f0486849450e510a8c727b7b79cb..b5c1716364258f079eac366ff1f0e08d87fe1b9d 100644 (file)
@@ -55,7 +55,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
         })
         .collect();
     let (update_graph, last_active_indices) = client
-        .update_tx_graph(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)
+        .scan_txs_with_keychains(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)
         .await?;
     let missing_heights = wallet.tx_graph().missing_heights(wallet.local_chain());
     let chain_update = client.update_local_chain(prev_tip, missing_heights).await?;
index d108742a5312ebdb9fba6af01ca44b70ad59e936..4001858de3f6a5acaa1bd7cb3e3bfc083117cd39 100644 (file)
@@ -55,7 +55,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
         .collect();
 
     let (update_graph, last_active_indices) =
-        client.update_tx_graph(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)?;
+        client.scan_txs_with_keychains(keychain_spks, None, None, STOP_GAP, PARALLEL_REQUESTS)?;
     let missing_heights = wallet.tx_graph().missing_heights(wallet.local_chain());
     let chain_update = client.update_local_chain(prev_tip, missing_heights)?;
     let update = WalletUpdate {