Skip to content

Commit d949fe4

Browse files
committed
Merge #1732: chore(core)!: rename SyncResult to SyncResponse
3b03c7b chore(core)!: rename `FullScanResult` to `FullScanResponse` (Leonardo Lima) 1411cb8 chore(core)!: rename `SyncResult` to `SyncResponse` (Leonardo Lima) Pull request description: fixes #1647 <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description As mentioned in #1647 issue, the usage of `Result` in Rust is conventionally meant to be an enum type with error variant, and it's appropriate here. It should be `SyncResponse` instead, as it's the most appropriate alongside the other types `SyncRequest` and `SyncProgress` already being used. <!-- Describe the purpose of this PR, what's being adding and/or fixed --> ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ### Changelog notice <!-- Notice the release manager should include in the release tag message changelog --> <!-- See https://keepachangelog.com/en/1.0.0/ for examples --> - Change `bdk_core::spk_client`'s `SyncResult` to `SyncResponse`. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [ ] I've added tests for the new feature * [ ] I've added docs for the new feature #### Bugfixes: * [ ] This pull request breaks the existing API * [ ] I've added tests to reproduce the issue which are now passing * [ ] I'm linking the issue being fixed by this PR ACKs for top commit: notmandatory: reACK 3b03c7b Tree-SHA512: b18c44b73f21d318f9f5f61417c0244a5b1c3cea9cab6490084edb380495e58d6e078b48b4e106bb2749b08da4f4e260b497ad482342b8fb7ee9b5e5dff2e4aa
2 parents 35e7051 + 3b03c7b commit d949fe4

File tree

7 files changed

+35
-35
lines changed

7 files changed

+35
-35
lines changed

crates/core/src/spk_client.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,14 @@ impl<I> SyncRequest<I> {
322322
/// See also [`SyncRequest`].
323323
#[must_use]
324324
#[derive(Debug)]
325-
pub struct SyncResult<A = ConfirmationBlockTime> {
325+
pub struct SyncResponse<A = ConfirmationBlockTime> {
326326
/// Relevant transaction data discovered during the scan.
327327
pub tx_update: crate::TxUpdate<A>,
328328
/// Changes to the chain discovered during the scan.
329329
pub chain_update: Option<CheckPoint>,
330330
}
331331

332-
impl<A> Default for SyncResult<A> {
332+
impl<A> Default for SyncResponse<A> {
333333
fn default() -> Self {
334334
Self {
335335
tx_update: Default::default(),
@@ -459,7 +459,7 @@ impl<K: Ord + Clone> FullScanRequest<K> {
459459
/// See also [`FullScanRequest`].
460460
#[must_use]
461461
#[derive(Debug)]
462-
pub struct FullScanResult<K, A = ConfirmationBlockTime> {
462+
pub struct FullScanResponse<K, A = ConfirmationBlockTime> {
463463
/// Relevant transaction data discovered during the scan.
464464
pub tx_update: crate::TxUpdate<A>,
465465
/// Last active indices for the corresponding keychains (`K`). An index is active if it had a
@@ -469,7 +469,7 @@ pub struct FullScanResult<K, A = ConfirmationBlockTime> {
469469
pub chain_update: Option<CheckPoint>,
470470
}
471471

472-
impl<K, A> Default for FullScanResult<K, A> {
472+
impl<K, A> Default for FullScanResponse<K, A> {
473473
fn default() -> Self {
474474
Self {
475475
tx_update: Default::default(),

crates/electrum/src/bdk_electrum_client.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use bdk_core::{
22
bitcoin::{block::Header, BlockHash, OutPoint, ScriptBuf, Transaction, Txid},
33
collections::{BTreeMap, HashMap},
4-
spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult},
4+
spk_client::{FullScanRequest, FullScanResponse, SyncRequest, SyncResponse},
55
BlockId, CheckPoint, ConfirmationBlockTime, TxUpdate,
66
};
77
use electrum_client::{ElectrumApi, Error, HeaderNotification};
@@ -126,7 +126,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
126126
stop_gap: usize,
127127
batch_size: usize,
128128
fetch_prev_txouts: bool,
129-
) -> Result<FullScanResult<K>, Error> {
129+
) -> Result<FullScanResponse<K>, Error> {
130130
let mut request: FullScanRequest<K> = request.into();
131131

132132
let tip_and_latest_blocks = match request.chain_tip() {
@@ -159,7 +159,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
159159
_ => None,
160160
};
161161

162-
Ok(FullScanResult {
162+
Ok(FullScanResponse {
163163
tx_update,
164164
chain_update,
165165
last_active_indices,
@@ -194,7 +194,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
194194
request: impl Into<SyncRequest<I>>,
195195
batch_size: usize,
196196
fetch_prev_txouts: bool,
197-
) -> Result<SyncResult, Error> {
197+
) -> Result<SyncResponse, Error> {
198198
let mut request: SyncRequest<I> = request.into();
199199

200200
let tip_and_latest_blocks = match request.chain_tip() {
@@ -229,7 +229,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
229229
None => None,
230230
};
231231

232-
Ok(SyncResult {
232+
Ok(SyncResponse {
233233
tx_update,
234234
chain_update,
235235
})

crates/electrum/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This crate is used for returning updates from Electrum servers.
22
//!
3-
//! Updates are returned as either a [`SyncResult`] (if [`BdkElectrumClient::sync()`] is called),
4-
//! or a [`FullScanResult`] (if [`BdkElectrumClient::full_scan()`] is called).
3+
//! Updates are returned as either a [`SyncResponse`] (if [`BdkElectrumClient::sync()`] is called),
4+
//! or a [`FullScanResponse`] (if [`BdkElectrumClient::full_scan()`] is called).
55
//!
66
//! In most cases [`BdkElectrumClient::sync()`] is used to sync the transaction histories of scripts
77
//! that the application cares about, for example the scripts for all the receive addresses of a
@@ -14,8 +14,8 @@
1414
//! Refer to [`example_electrum`] for a complete example.
1515
//!
1616
//! [`example_electrum`]: https://github.com/bitcoindevkit/bdk/tree/master/example-crates/example_electrum
17-
//! [`SyncResult`]: bdk_core::spk_client::SyncResult
18-
//! [`FullScanResult`]: bdk_core::spk_client::FullScanResult
17+
//! [`SyncResponse`]: bdk_core::spk_client::SyncResponse
18+
//! [`FullScanResponse`]: bdk_core::spk_client::FullScanResponse
1919
2020
#![warn(missing_docs)]
2121

crates/electrum/tests/test_electrum.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use bdk_chain::{
22
bitcoin::{hashes::Hash, Address, Amount, ScriptBuf, WScriptHash},
33
local_chain::LocalChain,
4-
spk_client::{FullScanRequest, SyncRequest, SyncResult},
4+
spk_client::{FullScanRequest, SyncRequest, SyncResponse},
55
spk_txout::SpkTxOutIndex,
66
Balance, ConfirmationBlockTime, IndexedTxGraph, Indexer, Merge, TxGraph,
77
};
@@ -31,7 +31,7 @@ fn sync_with_electrum<I, Spks>(
3131
spks: Spks,
3232
chain: &mut LocalChain,
3333
graph: &mut IndexedTxGraph<ConfirmationBlockTime, I>,
34-
) -> anyhow::Result<SyncResult>
34+
) -> anyhow::Result<SyncResponse>
3535
where
3636
I: Indexer,
3737
I::ChangeSet: Default + Merge,

crates/esplora/src/async_ext.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use async_trait::async_trait;
22
use bdk_core::collections::{BTreeMap, BTreeSet, HashSet};
3-
use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult};
3+
use bdk_core::spk_client::{FullScanRequest, FullScanResponse, SyncRequest, SyncResponse};
44
use bdk_core::{
55
bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid},
66
BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate,
@@ -32,7 +32,7 @@ pub trait EsploraAsyncExt {
3232
request: R,
3333
stop_gap: usize,
3434
parallel_requests: usize,
35-
) -> Result<FullScanResult<K>, Error>;
35+
) -> Result<FullScanResponse<K>, Error>;
3636

3737
/// Sync a set of scripts, txids, and/or outpoints against Esplora.
3838
///
@@ -45,7 +45,7 @@ pub trait EsploraAsyncExt {
4545
&self,
4646
request: R,
4747
parallel_requests: usize,
48-
) -> Result<SyncResult, Error>;
48+
) -> Result<SyncResponse, Error>;
4949
}
5050

5151
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
@@ -56,7 +56,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
5656
request: R,
5757
stop_gap: usize,
5858
parallel_requests: usize,
59-
) -> Result<FullScanResult<K>, Error> {
59+
) -> Result<FullScanResponse<K>, Error> {
6060
let mut request = request.into();
6161
let keychains = request.keychains();
6262

@@ -93,7 +93,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
9393
_ => None,
9494
};
9595

96-
Ok(FullScanResult {
96+
Ok(FullScanResponse {
9797
chain_update,
9898
tx_update,
9999
last_active_indices,
@@ -104,7 +104,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
104104
&self,
105105
request: R,
106106
parallel_requests: usize,
107-
) -> Result<SyncResult, Error> {
107+
) -> Result<SyncResponse, Error> {
108108
let mut request = request.into();
109109

110110
let chain_tip = request.chain_tip();
@@ -151,7 +151,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient {
151151
_ => None,
152152
};
153153

154-
Ok(SyncResult {
154+
Ok(SyncResponse {
155155
chain_update,
156156
tx_update,
157157
})

crates/esplora/src/blocking_ext.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bdk_core::collections::{BTreeMap, BTreeSet, HashSet};
2-
use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult};
2+
use bdk_core::spk_client::{FullScanRequest, FullScanResponse, SyncRequest, SyncResponse};
33
use bdk_core::{
44
bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid},
55
BlockId, CheckPoint, ConfirmationBlockTime, Indexed, TxUpdate,
@@ -30,7 +30,7 @@ pub trait EsploraExt {
3030
request: R,
3131
stop_gap: usize,
3232
parallel_requests: usize,
33-
) -> Result<FullScanResult<K>, Error>;
33+
) -> Result<FullScanResponse<K>, Error>;
3434

3535
/// Sync a set of scripts, txids, and/or outpoints against Esplora.
3636
///
@@ -43,7 +43,7 @@ pub trait EsploraExt {
4343
&self,
4444
request: R,
4545
parallel_requests: usize,
46-
) -> Result<SyncResult, Error>;
46+
) -> Result<SyncResponse, Error>;
4747
}
4848

4949
impl EsploraExt for esplora_client::BlockingClient {
@@ -52,7 +52,7 @@ impl EsploraExt for esplora_client::BlockingClient {
5252
request: R,
5353
stop_gap: usize,
5454
parallel_requests: usize,
55-
) -> Result<FullScanResult<K>, Error> {
55+
) -> Result<FullScanResponse<K>, Error> {
5656
let mut request = request.into();
5757

5858
let chain_tip = request.chain_tip();
@@ -90,7 +90,7 @@ impl EsploraExt for esplora_client::BlockingClient {
9090
_ => None,
9191
};
9292

93-
Ok(FullScanResult {
93+
Ok(FullScanResponse {
9494
chain_update,
9595
tx_update,
9696
last_active_indices,
@@ -101,7 +101,7 @@ impl EsploraExt for esplora_client::BlockingClient {
101101
&self,
102102
request: R,
103103
parallel_requests: usize,
104-
) -> Result<SyncResult, Error> {
104+
) -> Result<SyncResponse, Error> {
105105
let mut request: SyncRequest<I> = request.into();
106106

107107
let chain_tip = request.chain_tip();
@@ -142,7 +142,7 @@ impl EsploraExt for esplora_client::BlockingClient {
142142
_ => None,
143143
};
144144

145-
Ok(SyncResult {
145+
Ok(SyncResponse {
146146
chain_update,
147147
tx_update,
148148
})

crates/wallet/src/wallet/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use bdk_chain::{
2626
indexer::keychain_txout::KeychainTxOutIndex,
2727
local_chain::{ApplyHeaderError, CannotConnectError, CheckPoint, CheckPointIter, LocalChain},
2828
spk_client::{
29-
FullScanRequest, FullScanRequestBuilder, FullScanResult, SyncRequest, SyncRequestBuilder,
30-
SyncResult,
29+
FullScanRequest, FullScanRequestBuilder, FullScanResponse, SyncRequest, SyncRequestBuilder,
30+
SyncResponse,
3131
},
3232
tx_graph::{CalculateFeeError, CanonicalTx, TxGraph, TxUpdate},
3333
BlockId, ChainPosition, ConfirmationBlockTime, DescriptorExt, FullTxOut, Indexed,
@@ -130,8 +130,8 @@ pub struct Update {
130130
pub chain: Option<CheckPoint>,
131131
}
132132

133-
impl From<FullScanResult<KeychainKind>> for Update {
134-
fn from(value: FullScanResult<KeychainKind>) -> Self {
133+
impl From<FullScanResponse<KeychainKind>> for Update {
134+
fn from(value: FullScanResponse<KeychainKind>) -> Self {
135135
Self {
136136
last_active_indices: value.last_active_indices,
137137
tx_update: value.tx_update,
@@ -140,8 +140,8 @@ impl From<FullScanResult<KeychainKind>> for Update {
140140
}
141141
}
142142

143-
impl From<SyncResult> for Update {
144-
fn from(value: SyncResult) -> Self {
143+
impl From<SyncResponse> for Update {
144+
fn from(value: SyncResponse) -> Self {
145145
Self {
146146
last_active_indices: BTreeMap::new(),
147147
tx_update: value.tx_update,

0 commit comments

Comments
 (0)