From 1411cb8d58f669054c10c0dcfe67e6b271368544 Mon Sep 17 00:00:00 2001 From: Leonardo Lima Date: Tue, 19 Nov 2024 00:15:25 -0300 Subject: [PATCH] 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,