]> Untitled Git - bdk/commitdiff
[chain_redesign] Relax generic constraints
author志宇 <hello@evanlinjin.me>
Wed, 3 May 2023 07:20:49 +0000 (15:20 +0800)
committer志宇 <hello@evanlinjin.me>
Fri, 5 May 2023 08:35:39 +0000 (16:35 +0800)
crates/chain/src/indexed_tx_graph.rs
crates/chain/src/keychain/txout_index.rs
crates/chain/src/spk_txout_index.rs

index 6d8c16ffa1fd71ff0d2905b54333f08b187e2fd8..c550d86f07ddd42e804b35678a9fc2dc8edae77c 100644 (file)
@@ -12,6 +12,7 @@ use crate::{
 /// A struct that combines [`TxGraph`] and an [`Indexer`] implementation.
 ///
 /// This structure ensures that [`TxGraph`] and [`Indexer`] are updated atomically.
+#[derive(Debug)]
 pub struct IndexedTxGraph<A, I> {
     /// Transaction index.
     pub index: I,
@@ -27,12 +28,14 @@ impl<A, I: Default> Default for IndexedTxGraph<A, I> {
     }
 }
 
-impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I> {
+impl<A, I> IndexedTxGraph<A, I> {
     /// Get a reference of the internal transaction graph.
     pub fn graph(&self) -> &TxGraph<A> {
         &self.graph
     }
+}
 
+impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I> {
     /// Applies the [`IndexedAdditions`] to the [`IndexedTxGraph`].
     pub fn apply_additions(&mut self, additions: IndexedAdditions<A, I::Additions>) {
         let IndexedAdditions {
@@ -217,7 +220,7 @@ impl<A: Anchor, I: OwnedIndexer> IndexedTxGraph<A, I> {
         C: ChainOracle,
         F: FnMut(&Script) -> bool,
     {
-        let tip_height = chain_tip.anchor_block().height;
+        let tip_height = chain_tip.height;
 
         let mut immature = 0;
         let mut trusted_pending = 0;
index f8ef46be7e6904938b4e2eb1d5d865a12ccc1f43..c7a8dd54b42746aff83608a42307dfa0766a16ae 100644 (file)
@@ -89,7 +89,7 @@ impl<K> Deref for KeychainTxOutIndex<K> {
     }
 }
 
-impl<K: Clone + Ord + Debug + 'static> Indexer for KeychainTxOutIndex<K> {
+impl<K: Clone + Ord + Debug> Indexer for KeychainTxOutIndex<K> {
     type Additions = DerivationAdditions<K>;
 
     fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {
@@ -109,9 +109,9 @@ impl<K: Clone + Ord + Debug + 'static> Indexer for KeychainTxOutIndex<K> {
     }
 }
 
-impl<K: Clone + Ord + Debug + 'static> OwnedIndexer for KeychainTxOutIndex<K> {
+impl<K: Clone + Ord + Debug> OwnedIndexer for KeychainTxOutIndex<K> {
     fn is_spk_owned(&self, spk: &Script) -> bool {
-        self.inner().is_spk_owned(spk)
+        self.index_of_spk(spk).is_some()
     }
 }
 
index 9fdf3bc04394159adf6107fdb775fee51bdc1983..ae94414921c103635ea71c4232f96f3de06efcca 100644 (file)
@@ -53,7 +53,7 @@ impl<I> Default for SpkTxOutIndex<I> {
     }
 }
 
-impl<I: Clone + Ord + 'static> Indexer for SpkTxOutIndex<I> {
+impl<I: Clone + Ord> Indexer for SpkTxOutIndex<I> {
     type Additions = ();
 
     fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {