[bdk_chain_redesign] Implement OwnedIndexer
for indexers
`SpkTxOutIndex` and `KeychainTxOutIndex` now both implement `OwnedIndexer`.
This commit is contained in:
parent
911af34f50
commit
8cd0328eec
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
collections::*,
|
||||
indexed_tx_graph::Indexer,
|
||||
indexed_tx_graph::{Indexer, OwnedIndexer},
|
||||
miniscript::{Descriptor, DescriptorPublicKey},
|
||||
ForEachTxOut, SpkTxOutIndex,
|
||||
};
|
||||
@ -111,6 +111,12 @@ impl<K: Clone + Ord + Debug + 'static> Indexer for KeychainTxOutIndex<K> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + Ord + Debug + 'static> OwnedIndexer for KeychainTxOutIndex<K> {
|
||||
fn is_spk_owned(&self, spk: &Script) -> bool {
|
||||
self.inner().is_spk_owned(spk)
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
|
||||
/// Scans an object for relevant outpoints, which are stored and indexed internally.
|
||||
///
|
||||
|
@ -2,7 +2,7 @@ use core::ops::RangeBounds;
|
||||
|
||||
use crate::{
|
||||
collections::{hash_map::Entry, BTreeMap, BTreeSet, HashMap},
|
||||
indexed_tx_graph::Indexer,
|
||||
indexed_tx_graph::{Indexer, OwnedIndexer},
|
||||
ForEachTxOut,
|
||||
};
|
||||
use bitcoin::{self, OutPoint, Script, Transaction, TxOut, Txid};
|
||||
@ -75,6 +75,12 @@ impl<I: Clone + Ord + 'static> Indexer for SpkTxOutIndex<I> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Clone + Ord + 'static> OwnedIndexer for SpkTxOutIndex<I> {
|
||||
fn is_spk_owned(&self, spk: &Script) -> bool {
|
||||
self.spk_indices.get(spk).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
/// This macro is used instead of a member function of `SpkTxOutIndex`, which would result in a
|
||||
/// compiler error[E0521]: "borrowed data escapes out of closure" when we attempt to take a
|
||||
/// reference out of the `ForEachTxOut` closure during scanning.
|
||||
|
Loading…
x
Reference in New Issue
Block a user