From 11c0c0b9d526ffd4936d94c49ece1c70e746ff81 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Sun, 12 Nov 2023 21:09:04 -0600 Subject: [PATCH] refactor!(wallet): rename scan to full_scan refactor!(esplora): rename scan to full_scan, simplify scan_txs_with_keychain keychain_spks type --- crates/bdk/src/wallet/mod.rs | 8 ++++---- crates/esplora/src/async_ext.rs | 20 +++++++++---------- .../wallet_esplora_async/src/main.rs | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/crates/bdk/src/wallet/mod.rs b/crates/bdk/src/wallet/mod.rs index 968cbcaf6c..57186ac158 100644 --- a/crates/bdk/src/wallet/mod.rs +++ b/crates/bdk/src/wallet/mod.rs @@ -2020,11 +2020,11 @@ impl Wallet { &self.chain } - /// Get data needed to start a wallet scan + /// Get data needed to start a wallet full scan. /// /// Collect the wallet keychain script pub keys, local chain, and previous chain tip data needed - /// to start a blockchain scan. - pub fn start_scan( + /// to start a blockchain full scan. + pub fn start_full_scan( &self, ) -> ScanRequest + Clone> { let spks_by_keychain = self.spks_of_all_keychains(); @@ -2036,7 +2036,7 @@ impl Wallet { } } - /// Get data needed to start a wallet sync + /// Get data needed to start a wallet sync. /// /// Collect the wallet keychain script pub keys, local chain, previous chain tip, UTXOs, and /// unconfirmed transaction id data needed to start a blockchain sync. diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index e6678d4cf7..142858ece2 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -21,20 +21,21 @@ use crate::{anchor_from_status, ASSUME_FINAL_DEPTH}; #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait)] pub trait EsploraAsyncExt { - /// Scan keychain spks for transaction histories + /// Do a full scan of keychain spks to search for spks with transaction histories. /// - /// Scan iterates through spks of all keychains and collecting tx graph updates for + /// A full scan iterates through spks of all keychains and collecting tx graph updates for /// each spk. We start with the lowest derivation index spk and stop scanning after `stop_gap` - /// number of consecutive spks have no transaction history. A Scan is done in situations of - /// wallet restoration. It is a special case. Applications should use "sync" style updates - /// after an initial scan. + /// number of consecutive spks have no transaction history. + /// + /// A full scan is done in situations of wallet restoration. It is a special case. Applications + /// should use "sync" style updates after an initial full scan. /// /// A tuple is returned with the values: /// * last_active_indices, contains the last active derivation indices per keychain (`K`), /// which is used to update a wallets [`KeychainTxOutIndex`]. /// * graph_update, contains an update to a wallet's internal [`TxGraph`]. /// * chain_update, contains an update to a wallet's internal [`LocalChain`]. - async fn scan + Send>( + async fn full_scan + Send>( &self, scan_request: ScanRequest, stop_gap: usize, @@ -128,12 +129,9 @@ pub trait EsploraAsyncExt { /// transactions. `parallel_requests` specifies the max number of HTTP requests to make in /// parallel. #[allow(clippy::result_large_err)] - async fn scan_txs_with_keychains( + async fn scan_txs_with_keychains + Send>( &self, - keychain_spks: BTreeMap< - K, - impl IntoIterator + Send> + Send, - >, + keychain_spks: BTreeMap, txids: impl IntoIterator + Send> + Send, outpoints: impl IntoIterator + Send> + Send, stop_gap: usize, diff --git a/example-crates/wallet_esplora_async/src/main.rs b/example-crates/wallet_esplora_async/src/main.rs index 8f38ec48a3..7bf22affc8 100644 --- a/example-crates/wallet_esplora_async/src/main.rs +++ b/example-crates/wallet_esplora_async/src/main.rs @@ -42,9 +42,9 @@ async fn main() -> Result<(), Box> { // wallet restoration. It is a special case. Applications should use "sync" style updates // after an initial scan. if prompt("Scan wallet") { - let scan_request = wallet.start_scan(); + let scan_request = wallet.start_full_scan(); let wallet_update = client - .scan(scan_request, STOP_GAP, PARALLEL_REQUESTS) + .full_scan(scan_request, STOP_GAP, PARALLEL_REQUESTS) .await?; wallet.apply_update(wallet_update.into())?; wallet.commit()?;