From 1411cb8d58f669054c10c0dcfe67e6b271368544 Mon Sep 17 00:00:00 2001 From: Leonardo Lima Date: Tue, 19 Nov 2024 00:15:25 -0300 Subject: [PATCH 1/2] chore(core)!: rename `SyncResult` to `SyncResponse` --- crates/core/src/spk_client.rs | 4 ++-- crates/electrum/src/bdk_electrum_client.rs | 6 +++--- crates/electrum/src/lib.rs | 4 ++-- crates/electrum/tests/test_electrum.rs | 4 ++-- crates/esplora/src/async_ext.rs | 8 ++++---- crates/esplora/src/blocking_ext.rs | 8 ++++---- crates/wallet/src/wallet/mod.rs | 6 +++--- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/core/src/spk_client.rs b/crates/core/src/spk_client.rs index 1aceae5bb..e4090fb1d 100644 --- a/crates/core/src/spk_client.rs +++ b/crates/core/src/spk_client.rs @@ -322,14 +322,14 @@ impl SyncRequest { /// See also [`SyncRequest`]. #[must_use] #[derive(Debug)] -pub struct SyncResult { +pub struct SyncResponse { /// Relevant transaction data discovered during the scan. pub tx_update: crate::TxUpdate, /// Changes to the chain discovered during the scan. pub chain_update: Option, } -impl Default for SyncResult { +impl Default for SyncResponse { fn default() -> Self { Self { tx_update: Default::default(), diff --git a/crates/electrum/src/bdk_electrum_client.rs b/crates/electrum/src/bdk_electrum_client.rs index a98063336..e05e0db2d 100644 --- a/crates/electrum/src/bdk_electrum_client.rs +++ b/crates/electrum/src/bdk_electrum_client.rs @@ -1,7 +1,7 @@ use bdk_core::{ bitcoin::{block::Header, BlockHash, OutPoint, ScriptBuf, Transaction, Txid}, collections::{BTreeMap, HashMap}, - spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}, + spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResponse}, BlockId, CheckPoint, ConfirmationBlockTime, TxUpdate, }; use electrum_client::{ElectrumApi, Error, HeaderNotification}; @@ -194,7 +194,7 @@ impl BdkElectrumClient { request: impl Into>, batch_size: usize, fetch_prev_txouts: bool, - ) -> Result { + ) -> Result { let mut request: SyncRequest = request.into(); let tip_and_latest_blocks = match request.chain_tip() { @@ -229,7 +229,7 @@ impl BdkElectrumClient { None => None, }; - Ok(SyncResult { + Ok(SyncResponse { tx_update, chain_update, }) diff --git a/crates/electrum/src/lib.rs b/crates/electrum/src/lib.rs index 914b4f19a..797fc2c64 100644 --- a/crates/electrum/src/lib.rs +++ b/crates/electrum/src/lib.rs @@ -1,6 +1,6 @@ //! This crate is used for returning updates from Electrum servers. //! -//! Updates are returned as either a [`SyncResult`] (if [`BdkElectrumClient::sync()`] is called), +//! Updates are returned as either a [`SyncResponse`] (if [`BdkElectrumClient::sync()`] is called), //! or a [`FullScanResult`] (if [`BdkElectrumClient::full_scan()`] is called). //! //! In most cases [`BdkElectrumClient::sync()`] is used to sync the transaction histories of scripts @@ -14,7 +14,7 @@ //! Refer to [`example_electrum`] for a complete example. //! //! [`example_electrum`]: https://github.com/bitcoindevkit/bdk/tree/master/example-crates/example_electrum -//! [`SyncResult`]: bdk_core::spk_client::SyncResult +//! [`SyncResponse`]: bdk_core::spk_client::SyncResponse //! [`FullScanResult`]: bdk_core::spk_client::FullScanResult #![warn(missing_docs)] diff --git a/crates/electrum/tests/test_electrum.rs b/crates/electrum/tests/test_electrum.rs index 5f032ba6c..d2dba9d8d 100644 --- a/crates/electrum/tests/test_electrum.rs +++ b/crates/electrum/tests/test_electrum.rs @@ -1,7 +1,7 @@ use bdk_chain::{ bitcoin::{hashes::Hash, Address, Amount, ScriptBuf, WScriptHash}, local_chain::LocalChain, - spk_client::{FullScanRequest, SyncRequest, SyncResult}, + spk_client::{FullScanRequest, SyncRequest, SyncResponse}, spk_txout::SpkTxOutIndex, Balance, ConfirmationBlockTime, IndexedTxGraph, Indexer, Merge, TxGraph, }; @@ -31,7 +31,7 @@ fn sync_with_electrum( spks: Spks, chain: &mut LocalChain, graph: &mut IndexedTxGraph, -) -> anyhow::Result +) -> anyhow::Result where I: Indexer, I::ChangeSet: Default + Merge, diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index ca5111613..344f8dea0 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use bdk_core::collections::{BTreeMap, BTreeSet, HashSet}; -use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}; +use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResponse}; use bdk_core::{ bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid}, BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate, @@ -45,7 +45,7 @@ pub trait EsploraAsyncExt { &self, request: R, parallel_requests: usize, - ) -> Result; + ) -> Result; } #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] @@ -104,7 +104,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { &self, request: R, parallel_requests: usize, - ) -> Result { + ) -> Result { let mut request = request.into(); let chain_tip = request.chain_tip(); @@ -151,7 +151,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { _ => None, }; - Ok(SyncResult { + Ok(SyncResponse { chain_update, tx_update, }) diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index b740a21db..3e57cf0b6 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -1,5 +1,5 @@ use bdk_core::collections::{BTreeMap, BTreeSet, HashSet}; -use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}; +use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResponse}; use bdk_core::{ bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid}, BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate, @@ -43,7 +43,7 @@ pub trait EsploraExt { &self, request: R, parallel_requests: usize, - ) -> Result; + ) -> Result; } impl EsploraExt for esplora_client::BlockingClient { @@ -101,7 +101,7 @@ impl EsploraExt for esplora_client::BlockingClient { &self, request: R, parallel_requests: usize, - ) -> Result { + ) -> Result { let mut request: SyncRequest = request.into(); let chain_tip = request.chain_tip(); @@ -142,7 +142,7 @@ impl EsploraExt for esplora_client::BlockingClient { _ => None, }; - Ok(SyncResult { + Ok(SyncResponse { chain_update, tx_update, }) diff --git a/crates/wallet/src/wallet/mod.rs b/crates/wallet/src/wallet/mod.rs index 68d5e6bec..8f7221512 100644 --- a/crates/wallet/src/wallet/mod.rs +++ b/crates/wallet/src/wallet/mod.rs @@ -27,7 +27,7 @@ use bdk_chain::{ local_chain::{ApplyHeaderError, CannotConnectError, CheckPoint, CheckPointIter, LocalChain}, spk_client::{ FullScanRequest, FullScanRequestBuilder, FullScanResult, SyncRequest, SyncRequestBuilder, - SyncResult, + SyncResponse, }, tx_graph::{CalculateFeeError, CanonicalTx, TxGraph, TxUpdate}, BlockId, ChainPosition, ConfirmationBlockTime, DescriptorExt, FullTxOut, Indexed, @@ -142,8 +142,8 @@ impl From> for Update { } } -impl From for Update { - fn from(value: SyncResult) -> Self { +impl From for Update { + fn from(value: SyncResponse) -> Self { Self { last_active_indices: BTreeMap::new(), tx_update: value.tx_update, From 3b03c7bed2d132fbcdb027a8445f47f0b85d99fa Mon Sep 17 00:00:00 2001 From: Leonardo Lima Date: Wed, 20 Nov 2024 01:33:37 -0300 Subject: [PATCH 2/2] chore(core)!: rename `FullScanResult` to `FullScanResponse` --- crates/core/src/spk_client.rs | 4 ++-- crates/electrum/src/bdk_electrum_client.rs | 6 +++--- crates/electrum/src/lib.rs | 4 ++-- crates/esplora/src/async_ext.rs | 8 ++++---- crates/esplora/src/blocking_ext.rs | 8 ++++---- crates/wallet/src/wallet/mod.rs | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/core/src/spk_client.rs b/crates/core/src/spk_client.rs index e4090fb1d..eee4a5371 100644 --- a/crates/core/src/spk_client.rs +++ b/crates/core/src/spk_client.rs @@ -459,7 +459,7 @@ impl FullScanRequest { /// See also [`FullScanRequest`]. #[must_use] #[derive(Debug)] -pub struct FullScanResult { +pub struct FullScanResponse { /// Relevant transaction data discovered during the scan. pub tx_update: crate::TxUpdate, /// Last active indices for the corresponding keychains (`K`). An index is active if it had a @@ -469,7 +469,7 @@ pub struct FullScanResult { pub chain_update: Option, } -impl Default for FullScanResult { +impl Default for FullScanResponse { fn default() -> Self { Self { tx_update: Default::default(), diff --git a/crates/electrum/src/bdk_electrum_client.rs b/crates/electrum/src/bdk_electrum_client.rs index e05e0db2d..f9e53bff8 100644 --- a/crates/electrum/src/bdk_electrum_client.rs +++ b/crates/electrum/src/bdk_electrum_client.rs @@ -1,7 +1,7 @@ use bdk_core::{ bitcoin::{block::Header, BlockHash, OutPoint, ScriptBuf, Transaction, Txid}, collections::{BTreeMap, HashMap}, - spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResponse}, + spk_client::{FullScanRequest, FullScanResponse, SyncRequest, SyncResponse}, BlockId, CheckPoint, ConfirmationBlockTime, TxUpdate, }; use electrum_client::{ElectrumApi, Error, HeaderNotification}; @@ -126,7 +126,7 @@ impl BdkElectrumClient { stop_gap: usize, batch_size: usize, fetch_prev_txouts: bool, - ) -> Result, Error> { + ) -> Result, Error> { let mut request: FullScanRequest = request.into(); let tip_and_latest_blocks = match request.chain_tip() { @@ -159,7 +159,7 @@ impl BdkElectrumClient { _ => None, }; - Ok(FullScanResult { + Ok(FullScanResponse { tx_update, chain_update, last_active_indices, diff --git a/crates/electrum/src/lib.rs b/crates/electrum/src/lib.rs index 797fc2c64..8bc87321f 100644 --- a/crates/electrum/src/lib.rs +++ b/crates/electrum/src/lib.rs @@ -1,7 +1,7 @@ //! This crate is used for returning updates from Electrum servers. //! //! Updates are returned as either a [`SyncResponse`] (if [`BdkElectrumClient::sync()`] is called), -//! or a [`FullScanResult`] (if [`BdkElectrumClient::full_scan()`] is called). +//! or a [`FullScanResponse`] (if [`BdkElectrumClient::full_scan()`] is called). //! //! In most cases [`BdkElectrumClient::sync()`] is used to sync the transaction histories of scripts //! that the application cares about, for example the scripts for all the receive addresses of a @@ -15,7 +15,7 @@ //! //! [`example_electrum`]: https://github.com/bitcoindevkit/bdk/tree/master/example-crates/example_electrum //! [`SyncResponse`]: bdk_core::spk_client::SyncResponse -//! [`FullScanResult`]: bdk_core::spk_client::FullScanResult +//! [`FullScanResponse`]: bdk_core::spk_client::FullScanResponse #![warn(missing_docs)] diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index 344f8dea0..b9b7fa567 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -1,6 +1,6 @@ use async_trait::async_trait; use bdk_core::collections::{BTreeMap, BTreeSet, HashSet}; -use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResponse}; +use bdk_core::spk_client::{FullScanRequest, FullScanResponse, SyncRequest, SyncResponse}; use bdk_core::{ bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid}, BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate, @@ -32,7 +32,7 @@ pub trait EsploraAsyncExt { request: R, stop_gap: usize, parallel_requests: usize, - ) -> Result, Error>; + ) -> Result, Error>; /// Sync a set of scripts, txids, and/or outpoints against Esplora. /// @@ -56,7 +56,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { request: R, stop_gap: usize, parallel_requests: usize, - ) -> Result, Error> { + ) -> Result, Error> { let mut request = request.into(); let keychains = request.keychains(); @@ -93,7 +93,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { _ => None, }; - Ok(FullScanResult { + Ok(FullScanResponse { chain_update, tx_update, last_active_indices, diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 3e57cf0b6..655055b33 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -1,5 +1,5 @@ use bdk_core::collections::{BTreeMap, BTreeSet, HashSet}; -use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResponse}; +use bdk_core::spk_client::{FullScanRequest, FullScanResponse, SyncRequest, SyncResponse}; use bdk_core::{ bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid}, BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate, @@ -30,7 +30,7 @@ pub trait EsploraExt { request: R, stop_gap: usize, parallel_requests: usize, - ) -> Result, Error>; + ) -> Result, Error>; /// Sync a set of scripts, txids, and/or outpoints against Esplora. /// @@ -52,7 +52,7 @@ impl EsploraExt for esplora_client::BlockingClient { request: R, stop_gap: usize, parallel_requests: usize, - ) -> Result, Error> { + ) -> Result, Error> { let mut request = request.into(); let chain_tip = request.chain_tip(); @@ -90,7 +90,7 @@ impl EsploraExt for esplora_client::BlockingClient { _ => None, }; - Ok(FullScanResult { + Ok(FullScanResponse { chain_update, tx_update, last_active_indices, diff --git a/crates/wallet/src/wallet/mod.rs b/crates/wallet/src/wallet/mod.rs index 8f7221512..17bccb670 100644 --- a/crates/wallet/src/wallet/mod.rs +++ b/crates/wallet/src/wallet/mod.rs @@ -26,7 +26,7 @@ use bdk_chain::{ indexer::keychain_txout::KeychainTxOutIndex, local_chain::{ApplyHeaderError, CannotConnectError, CheckPoint, CheckPointIter, LocalChain}, spk_client::{ - FullScanRequest, FullScanRequestBuilder, FullScanResult, SyncRequest, SyncRequestBuilder, + FullScanRequest, FullScanRequestBuilder, FullScanResponse, SyncRequest, SyncRequestBuilder, SyncResponse, }, tx_graph::{CalculateFeeError, CanonicalTx, TxGraph, TxUpdate}, @@ -132,8 +132,8 @@ pub struct Update { pub chain: Option, } -impl From> for Update { - fn from(value: FullScanResult) -> Self { +impl From> for Update { + fn from(value: FullScanResponse) -> Self { Self { last_active_indices: value.last_active_indices, tx_update: value.tx_update,