Skip to content

Commit 1ff806c

Browse files
committed
fix(chain)!: rm weird From impl
And signature of `example_cli::KeychainChangeSet` is changed.
1 parent d43ae02 commit 1ff806c

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

crates/chain/src/indexed_tx_graph.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use alloc::vec::Vec;
66
use bitcoin::{OutPoint, Transaction, TxOut};
77

88
use crate::{
9-
keychain, local_chain,
9+
keychain,
1010
tx_graph::{self, TxGraph},
1111
Anchor, Append,
1212
};
@@ -225,12 +225,6 @@ impl<A, K> From<keychain::ChangeSet<K>> for ChangeSet<A, keychain::ChangeSet<K>>
225225
}
226226
}
227227

228-
impl<A, IA> From<ChangeSet<A, IA>> for (local_chain::ChangeSet, ChangeSet<A, IA>) {
229-
fn from(indexed_changeset: ChangeSet<A, IA>) -> Self {
230-
(local_chain::ChangeSet::default(), indexed_changeset)
231-
}
232-
}
233-
234228
/// Utilities for indexing transaction data.
235229
///
236230
/// Types which implement this trait can be used to construct an [`IndexedTxGraph`].

example-crates/example_cli/src/lib.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use bdk_chain::{
1212
},
1313
indexed_tx_graph::{self, IndexedTxGraph},
1414
keychain::{self, KeychainTxOutIndex},
15+
local_chain,
1516
miniscript::{
1617
descriptor::{DescriptorSecretKey, KeyMap},
1718
Descriptor, DescriptorPublicKey,
@@ -24,7 +25,10 @@ pub use clap;
2425
use clap::{Parser, Subcommand};
2526

2627
pub type KeychainTxGraph<A> = IndexedTxGraph<A, KeychainTxOutIndex<Keychain>>;
27-
pub type KeychainChangeSet<A> = indexed_tx_graph::ChangeSet<A, keychain::ChangeSet<Keychain>>;
28+
pub type KeychainChangeSet<A> = (
29+
local_chain::ChangeSet,
30+
indexed_tx_graph::ChangeSet<A, keychain::ChangeSet<Keychain>>,
31+
);
2832
pub type Database<'m, C> = Persist<Store<'m, C>, C>;
2933

3034
#[derive(Parser)]
@@ -200,7 +204,10 @@ where
200204

201205
let ((spk_i, spk), index_changeset) = spk_chooser(index, &Keychain::External);
202206
let db = &mut *db.lock().unwrap();
203-
db.stage(C::from(KeychainChangeSet::from(index_changeset)));
207+
db.stage(C::from((
208+
local_chain::ChangeSet::default(),
209+
indexed_tx_graph::ChangeSet::from(index_changeset),
210+
)));
204211
db.commit()?;
205212
let addr = Address::from_script(spk, network).context("failed to derive address")?;
206213
println!("[address @ {}] {}", spk_i, addr);
@@ -353,7 +360,10 @@ where
353360
// If we're unable to persist this, then we don't want to broadcast.
354361
{
355362
let db = &mut *db.lock().unwrap();
356-
db.stage(C::from(KeychainChangeSet::from(index_changeset)));
363+
db.stage(C::from((
364+
local_chain::ChangeSet::default(),
365+
indexed_tx_graph::ChangeSet::from(index_changeset),
366+
)));
357367
db.commit()?;
358368
}
359369

@@ -376,7 +386,10 @@ where
376386
// We know the tx is at least unconfirmed now. Note if persisting here fails,
377387
// it's not a big deal since we can always find it again form
378388
// blockchain.
379-
db.lock().unwrap().stage(C::from(keychain_changeset));
389+
db.lock().unwrap().stage(C::from((
390+
local_chain::ChangeSet::default(),
391+
keychain_changeset,
392+
)));
380393
Ok(())
381394
}
382395
Err(e) => {

0 commit comments

Comments
 (0)