]> Untitled Git - bdk/commitdiff
fix(chain)!: rm weird `From` impl
author志宇 <hello@evanlinjin.me>
Thu, 14 Sep 2023 12:14:42 +0000 (20:14 +0800)
committer志宇 <hello@evanlinjin.me>
Thu, 14 Sep 2023 12:16:00 +0000 (20:16 +0800)
And signature of `example_cli::KeychainChangeSet` is changed.

crates/chain/src/indexed_tx_graph.rs
example-crates/example_cli/src/lib.rs

index c9091eef959d4fdd55058b73830c3e2ae5ff2286..4df7e85e634dc8dd49e22160a76a06f54dccf4d0 100644 (file)
@@ -6,7 +6,7 @@ use alloc::vec::Vec;
 use bitcoin::{OutPoint, Transaction, TxOut};
 
 use crate::{
-    keychain, local_chain,
+    keychain,
     tx_graph::{self, TxGraph},
     Anchor, Append,
 };
@@ -225,12 +225,6 @@ impl<A, K> From<keychain::ChangeSet<K>> for ChangeSet<A, keychain::ChangeSet<K>>
     }
 }
 
-impl<A, IA> From<ChangeSet<A, IA>> for (local_chain::ChangeSet, ChangeSet<A, IA>) {
-    fn from(indexed_changeset: ChangeSet<A, IA>) -> Self {
-        (local_chain::ChangeSet::default(), indexed_changeset)
-    }
-}
-
 /// Utilities for indexing transaction data.
 ///
 /// Types which implement this trait can be used to construct an [`IndexedTxGraph`].
index 18bed2c93ba08c0bda14d1eabe3c31f8bee37ab3..c9459c353f9796db8e7cb05effcdcba4b292e3db 100644 (file)
@@ -12,6 +12,7 @@ use bdk_chain::{
     },
     indexed_tx_graph::{self, IndexedTxGraph},
     keychain::{self, KeychainTxOutIndex},
+    local_chain,
     miniscript::{
         descriptor::{DescriptorSecretKey, KeyMap},
         Descriptor, DescriptorPublicKey,
@@ -24,7 +25,10 @@ pub use clap;
 use clap::{Parser, Subcommand};
 
 pub type KeychainTxGraph<A> = IndexedTxGraph<A, KeychainTxOutIndex<Keychain>>;
-pub type KeychainChangeSet<A> = indexed_tx_graph::ChangeSet<A, keychain::ChangeSet<Keychain>>;
+pub type KeychainChangeSet<A> = (
+    local_chain::ChangeSet,
+    indexed_tx_graph::ChangeSet<A, keychain::ChangeSet<Keychain>>,
+);
 pub type Database<'m, C> = Persist<Store<'m, C>, C>;
 
 #[derive(Parser)]
@@ -200,7 +204,10 @@ where
 
             let ((spk_i, spk), index_changeset) = spk_chooser(index, &Keychain::External);
             let db = &mut *db.lock().unwrap();
-            db.stage(C::from(KeychainChangeSet::from(index_changeset)));
+            db.stage(C::from((
+                local_chain::ChangeSet::default(),
+                indexed_tx_graph::ChangeSet::from(index_changeset),
+            )));
             db.commit()?;
             let addr = Address::from_script(spk, network).context("failed to derive address")?;
             println!("[address @ {}] {}", spk_i, addr);
@@ -353,7 +360,10 @@ where
             // If we're unable to persist this, then we don't want to broadcast.
             {
                 let db = &mut *db.lock().unwrap();
-                db.stage(C::from(KeychainChangeSet::from(index_changeset)));
+                db.stage(C::from((
+                    local_chain::ChangeSet::default(),
+                    indexed_tx_graph::ChangeSet::from(index_changeset),
+                )));
                 db.commit()?;
             }
 
@@ -376,7 +386,10 @@ where
             // We know the tx is at least unconfirmed now. Note if persisting here fails,
             // it's not a big deal since we can always find it again form
             // blockchain.
-            db.lock().unwrap().stage(C::from(keychain_changeset));
+            db.lock().unwrap().stage(C::from((
+                local_chain::ChangeSet::default(),
+                keychain_changeset,
+            )));
             Ok(())
         }
         Err(e) => {