[bdk_chain_redesign] Simplify TxIndex

This commit is contained in:
志宇
2023-03-31 12:39:00 +08:00
parent a1172def7d
commit a63ffe9739
5 changed files with 86 additions and 124 deletions

View File

@@ -53,19 +53,16 @@ impl<I> Default for SpkTxOutIndex<I> {
}
impl<I: Clone + Ord + 'static> TxIndex for SpkTxOutIndex<I> {
type Additions = BTreeSet<I>;
type SpkIndex = I;
type Additions = ();
fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {
self.scan_txout(outpoint, txout)
.cloned()
.into_iter()
.collect()
self.scan_txout(outpoint, txout);
Default::default()
}
fn index_tx(&mut self, tx: &Transaction) -> Self::Additions {
self.scan(tx)
self.scan(tx);
Default::default()
}
fn apply_additions(&mut self, _additions: Self::Additions) {
@@ -76,8 +73,8 @@ impl<I: Clone + Ord + 'static> TxIndex for SpkTxOutIndex<I> {
self.is_relevant(tx)
}
fn relevant_txouts(&self) -> &BTreeMap<OutPoint, (Self::SpkIndex, TxOut)> {
&self.txouts
fn is_spk_owned(&self, spk: &Script) -> bool {
self.index_of_spk(spk).is_some()
}
}