Skip to content

Commit 8f550e4

Browse files
authored
Merge pull request #96 from rustaceanrob/return-type-1-20
Return `Update` from `UpdateSubscriber`
2 parents dff01cd + e52c6fb commit 8f550e4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ use std::collections::HashSet;
4646
type FutureResult<'a, T, E> = Pin<Box<dyn Future<Output = Result<T, E>> + Send + 'a>>;
4747

4848
pub use bdk_wallet::chain::local_chain::MissingGenesisError;
49+
pub use bdk_wallet::Update;
4950

5051
use bdk_wallet::chain::{
5152
keychain_txout::KeychainTxOutIndex,
5253
local_chain::{self, CheckPoint, LocalChain},
53-
spk_client::FullScanResponse,
5454
IndexedTxGraph,
5555
};
5656
use bdk_wallet::chain::{ConfirmationBlockTime, TxUpdate};
@@ -120,7 +120,7 @@ impl UpdateSubscriber {
120120
/// A reference to a [`NodeEventHandler`] is required, which handles events emitted from a
121121
/// running node. Production applications should define how the application handles
122122
/// these events and displays them to end users.
123-
pub async fn update(&mut self) -> Option<FullScanResponse<KeychainKind>> {
123+
pub async fn update(&mut self) -> Option<Update> {
124124
let mut chain_changeset = BTreeMap::new();
125125
while let Some(message) = self.receiver.recv().await {
126126
match message {
@@ -161,15 +161,15 @@ impl UpdateSubscriber {
161161

162162
// When the client is believed to have synced to the chain tip of most work,
163163
// we can return a wallet update.
164-
fn get_scan_response(&mut self) -> FullScanResponse<KeychainKind> {
164+
fn get_scan_response(&mut self) -> Update {
165165
let tx_update = TxUpdate::from(self.graph.graph().clone());
166166
let graph = core::mem::take(&mut self.graph);
167167
let last_active_indices = graph.index.last_used_indices();
168168
self.graph = IndexedTxGraph::new(graph.index);
169-
FullScanResponse {
169+
Update {
170170
tx_update,
171171
last_active_indices,
172-
chain_update: Some(self.chain.tip()),
172+
chain: Some(self.chain.tip()),
173173
}
174174
}
175175
}

tests/client.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use bdk_testenv::bitcoincore_rpc::RpcApi;
1212
use bdk_testenv::bitcoind;
1313
use bdk_testenv::TestEnv;
1414
use bdk_wallet::bitcoin::{Amount, Network};
15-
use bdk_wallet::chain::spk_client::FullScanResponse;
1615
use bdk_wallet::CreateParams;
1716
use bdk_wallet::KeychainKind;
17+
use bdk_wallet::Update;
1818

1919
const EXTERNAL_DESCRIPTOR: &str = "tr([7d94197e/86'/1'/0']tpubDCyQVJj8KzjiQsFjmb3KwECVXPvMwvAxxZGCP9XmWSopmjW3bCV3wD7TgxrUhiGSueDS1MU5X1Vb1YjYcp8jitXc5fXfdC1z68hDDEyKRNr/0/*)";
2020
const INTERNAL_DESCRIPTOR: &str = "tr([7d94197e/86'/1'/0']tpubDCyQVJj8KzjiQsFjmb3KwECVXPvMwvAxxZGCP9XmWSopmjW3bCV3wD7TgxrUhiGSueDS1MU5X1Vb1YjYcp8jitXc5fXfdC1z68hDDEyKRNr/1/*)";
@@ -98,9 +98,9 @@ async fn update_returns_blockchain_data() -> anyhow::Result<()> {
9898
.update()
9999
.await
100100
.expect("should have update");
101-
let FullScanResponse {
101+
let Update {
102102
tx_update,
103-
chain_update,
103+
chain,
104104
last_active_indices,
105105
} = res;
106106
// graph tx and anchor
@@ -112,7 +112,7 @@ async fn update_returns_blockchain_data() -> anyhow::Result<()> {
112112
let txout = tx.output.iter().find(|txout| txout.value == amt).unwrap();
113113
assert_eq!(txout.script_pubkey, addr.script_pubkey());
114114
// chain
115-
let update_cp = chain_update.unwrap();
115+
let update_cp = chain.unwrap();
116116
assert_eq!(update_cp.height(), 102);
117117
// keychain
118118
assert_eq!(

0 commit comments

Comments
 (0)