Skip to content

Commit

Permalink
chore(core)!: rename SyncResult to SyncResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
oleonardolima committed Nov 19, 2024
1 parent 3bc45b5 commit 1411cb8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions crates/core/src/spk_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ impl<I> SyncRequest<I> {
/// See also [`SyncRequest`].
#[must_use]
#[derive(Debug)]
pub struct SyncResult<A = ConfirmationBlockTime> {
pub struct SyncResponse<A = ConfirmationBlockTime> {
/// Relevant transaction data discovered during the scan.
pub tx_update: crate::TxUpdate<A>,
/// Changes to the chain discovered during the scan.
pub chain_update: Option<CheckPoint>,
}

impl<A> Default for SyncResult<A> {
impl<A> Default for SyncResponse<A> {
fn default() -> Self {
Self {
tx_update: Default::default(),
Expand Down
6 changes: 3 additions & 3 deletions crates/electrum/src/bdk_electrum_client.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -194,7 +194,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
request: impl Into<SyncRequest<I>>,
batch_size: usize,
fetch_prev_txouts: bool,
) -> Result<SyncResult, Error> {
) -> Result<SyncResponse, Error> {
let mut request: SyncRequest<I> = request.into();

let tip_and_latest_blocks = match request.chain_tip() {
Expand Down Expand Up @@ -229,7 +229,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
None => None,
};

Ok(SyncResult {
Ok(SyncResponse {
tx_update,
chain_update,
})
Expand Down
4 changes: 2 additions & 2 deletions crates/electrum/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions crates/electrum/tests/test_electrum.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down Expand Up @@ -31,7 +31,7 @@ fn sync_with_electrum<I, Spks>(
spks: Spks,
chain: &mut LocalChain,
graph: &mut IndexedTxGraph<ConfirmationBlockTime, I>,
) -> anyhow::Result<SyncResult>
) -> anyhow::Result<SyncResponse>
where
I: Indexer,
I::ChangeSet: Default + Merge,
Expand Down
8 changes: 4 additions & 4 deletions crates/esplora/src/async_ext.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -45,7 +45,7 @@ pub trait EsploraAsyncExt {
&self,
request: R,
parallel_requests: usize,
) -> Result<SyncResult, Error>;
) -> Result<SyncResponse, Error>;
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
Expand Down Expand Up @@ -104,7 +104,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
&self,
request: R,
parallel_requests: usize,
) -> Result<SyncResult, Error> {
) -> Result<SyncResponse, Error> {
let mut request = request.into();

let chain_tip = request.chain_tip();
Expand Down Expand Up @@ -151,7 +151,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
_ => None,
};

Ok(SyncResult {
Ok(SyncResponse {
chain_update,
tx_update,
})
Expand Down
8 changes: 4 additions & 4 deletions crates/esplora/src/blocking_ext.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -43,7 +43,7 @@ pub trait EsploraExt {
&self,
request: R,
parallel_requests: usize,
) -> Result<SyncResult, Error>;
) -> Result<SyncResponse, Error>;
}

impl EsploraExt for esplora_client::BlockingClient {
Expand Down Expand Up @@ -101,7 +101,7 @@ impl EsploraExt for esplora_client::BlockingClient {
&self,
request: R,
parallel_requests: usize,
) -> Result<SyncResult, Error> {
) -> Result<SyncResponse, Error> {
let mut request: SyncRequest<I> = request.into();

let chain_tip = request.chain_tip();
Expand Down Expand Up @@ -142,7 +142,7 @@ impl EsploraExt for esplora_client::BlockingClient {
_ => None,
};

Ok(SyncResult {
Ok(SyncResponse {
chain_update,
tx_update,
})
Expand Down
6 changes: 3 additions & 3 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -142,8 +142,8 @@ impl From<FullScanResult<KeychainKind>> for Update {
}
}

impl From<SyncResult> for Update {
fn from(value: SyncResult) -> Self {
impl From<SyncResponse> for Update {
fn from(value: SyncResponse) -> Self {
Self {
last_active_indices: BTreeMap::new(),
tx_update: value.tx_update,
Expand Down

0 comments on commit 1411cb8

Please sign in to comment.