Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 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 Expand Up @@ -459,7 +459,7 @@ impl<K: Ord + Clone> FullScanRequest<K> {
/// See also [`FullScanRequest`].
#[must_use]
#[derive(Debug)]
pub struct FullScanResult<K, A = ConfirmationBlockTime> {
pub struct FullScanResponse<K, A = ConfirmationBlockTime> {
/// Relevant transaction data discovered during the scan.
pub tx_update: crate::TxUpdate<A>,
/// Last active indices for the corresponding keychains (`K`). An index is active if it had a
Expand All @@ -469,7 +469,7 @@ pub struct FullScanResult<K, A = ConfirmationBlockTime> {
pub chain_update: Option<CheckPoint>,
}

impl<K, A> Default for FullScanResult<K, A> {
impl<K, A> Default for FullScanResponse<K, A> {
fn default() -> Self {
Self {
tx_update: Default::default(),
Expand Down
10 changes: 5 additions & 5 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, FullScanResponse, SyncRequest, SyncResponse},
BlockId, CheckPoint, ConfirmationBlockTime, TxUpdate,
};
use electrum_client::{ElectrumApi, Error, HeaderNotification};
Expand Down Expand Up @@ -126,7 +126,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
stop_gap: usize,
batch_size: usize,
fetch_prev_txouts: bool,
) -> Result<FullScanResult<K>, Error> {
) -> Result<FullScanResponse<K>, Error> {
let mut request: FullScanRequest<K> = request.into();

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

Ok(FullScanResult {
Ok(FullScanResponse {
tx_update,
chain_update,
last_active_indices,
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
8 changes: 4 additions & 4 deletions crates/electrum/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! This crate is used for returning updates from Electrum servers.
//!
//! Updates are returned as either a [`SyncResult`] (if [`BdkElectrumClient::sync()`] is called),
//! or a [`FullScanResult`] (if [`BdkElectrumClient::full_scan()`] is called).
//! Updates are returned as either a [`SyncResponse`] (if [`BdkElectrumClient::sync()`] 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
Expand All @@ -14,8 +14,8 @@
//! 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
//! [`FullScanResult`]: bdk_core::spk_client::FullScanResult
//! [`SyncResponse`]: bdk_core::spk_client::SyncResponse
//! [`FullScanResponse`]: bdk_core::spk_client::FullScanResponse

#![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
14 changes: 7 additions & 7 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, FullScanResponse, SyncRequest, SyncResponse};
use bdk_core::{
bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid},
BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate,
Expand Down Expand Up @@ -32,7 +32,7 @@ pub trait EsploraAsyncExt {
request: R,
stop_gap: usize,
parallel_requests: usize,
) -> Result<FullScanResult<K>, Error>;
) -> Result<FullScanResponse<K>, Error>;

/// Sync a set of scripts, txids, and/or outpoints against Esplora.
///
Expand All @@ -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 All @@ -56,7 +56,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
request: R,
stop_gap: usize,
parallel_requests: usize,
) -> Result<FullScanResult<K>, Error> {
) -> Result<FullScanResponse<K>, Error> {
let mut request = request.into();
let keychains = request.keychains();

Expand Down Expand Up @@ -93,7 +93,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
_ => None,
};

Ok(FullScanResult {
Ok(FullScanResponse {
chain_update,
tx_update,
last_active_indices,
Expand All @@ -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
14 changes: 7 additions & 7 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, FullScanResponse, SyncRequest, SyncResponse};
use bdk_core::{
bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid},
BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate,
Expand Down Expand Up @@ -30,7 +30,7 @@ pub trait EsploraExt {
request: R,
stop_gap: usize,
parallel_requests: usize,
) -> Result<FullScanResult<K>, Error>;
) -> Result<FullScanResponse<K>, Error>;

/// Sync a set of scripts, txids, and/or outpoints against Esplora.
///
Expand All @@ -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 All @@ -52,7 +52,7 @@ impl EsploraExt for esplora_client::BlockingClient {
request: R,
stop_gap: usize,
parallel_requests: usize,
) -> Result<FullScanResult<K>, Error> {
) -> Result<FullScanResponse<K>, Error> {
let mut request = request.into();

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

Ok(FullScanResult {
Ok(FullScanResponse {
chain_update,
tx_update,
last_active_indices,
Expand All @@ -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
12 changes: 6 additions & 6 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use bdk_chain::{
indexer::keychain_txout::KeychainTxOutIndex,
local_chain::{ApplyHeaderError, CannotConnectError, CheckPoint, CheckPointIter, LocalChain},
spk_client::{
FullScanRequest, FullScanRequestBuilder, FullScanResult, SyncRequest, SyncRequestBuilder,
SyncResult,
FullScanRequest, FullScanRequestBuilder, FullScanResponse, SyncRequest, SyncRequestBuilder,
SyncResponse,
},
tx_graph::{CalculateFeeError, CanonicalTx, TxGraph, TxUpdate},
BlockId, ChainPosition, ConfirmationBlockTime, DescriptorExt, FullTxOut, Indexed,
Expand Down Expand Up @@ -132,8 +132,8 @@ pub struct Update {
pub chain: Option<CheckPoint>,
}

impl From<FullScanResult<KeychainKind>> for Update {
fn from(value: FullScanResult<KeychainKind>) -> Self {
impl From<FullScanResponse<KeychainKind>> for Update {
fn from(value: FullScanResponse<KeychainKind>) -> Self {
Self {
last_active_indices: value.last_active_indices,
tx_update: value.tx_update,
Expand All @@ -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