From 585986cab40c51e03e4017292f4355053f880977 Mon Sep 17 00:00:00 2001 From: Vladimir Fomene Date: Thu, 12 Oct 2023 19:04:00 +0300 Subject: [PATCH] feat: implement default index_tx method --- .github/workflows/cont_integration.yml | 2 +- crates/chain/src/indexed_tx_graph.rs | 10 ++++++++-- crates/chain/src/keychain/txout_index.rs | 8 -------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 4d60f15b97..6e3c457cd3 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -36,7 +36,7 @@ jobs: cargo update -p rustls:0.20.9 --precise "0.20.8" cargo update -p tokio:1.33.0 --precise "1.29.1" cargo update -p tokio-util --precise "0.7.8" - cargo update -p flate2:1.0.27 --precise "1.0.26" + cargo update -p flate2:1.0.28 --precise "1.0.26" cargo update -p reqwest --precise "0.11.18" cargo update -p h2 --precise "0.3.20" cargo update -p rustls-webpki:0.100.3 --precise "0.100.1" diff --git a/crates/chain/src/indexed_tx_graph.rs b/crates/chain/src/indexed_tx_graph.rs index 0e2620e0d1..9f734df3ae 100644 --- a/crates/chain/src/indexed_tx_graph.rs +++ b/crates/chain/src/indexed_tx_graph.rs @@ -331,13 +331,19 @@ impl From> for ChangeSet> /// This trait's methods should rarely be called directly. pub trait Indexer { /// The resultant "changeset" when new transaction data is indexed. - type ChangeSet; + type ChangeSet: Append + Default; /// Scan and index the given `outpoint` and `txout`. fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::ChangeSet; /// Scans a transaction for relevant outpoints, which are stored and indexed internally. - fn index_tx(&mut self, tx: &Transaction) -> Self::ChangeSet; + fn index_tx(&mut self, tx: &Transaction) -> Self::ChangeSet { + let mut changeset = Self::ChangeSet::default(); + for (op, txout) in tx.output.iter().enumerate() { + changeset.append(self.index_txout(OutPoint::new(tx.txid(), op as u32), txout)); + } + changeset + } /// Apply changeset to itself. fn apply_changeset(&mut self, changeset: Self::ChangeSet); diff --git a/crates/chain/src/keychain/txout_index.rs b/crates/chain/src/keychain/txout_index.rs index 2089673bae..6d3f096ef7 100644 --- a/crates/chain/src/keychain/txout_index.rs +++ b/crates/chain/src/keychain/txout_index.rs @@ -97,14 +97,6 @@ impl Indexer for KeychainTxOutIndex { } } - fn index_tx(&mut self, tx: &bitcoin::Transaction) -> Self::ChangeSet { - let mut changeset = super::ChangeSet::::default(); - for (op, txout) in tx.output.iter().enumerate() { - changeset.append(self.index_txout(OutPoint::new(tx.txid(), op as u32), txout)); - } - changeset - } - fn initial_changeset(&self) -> Self::ChangeSet { super::ChangeSet(self.last_revealed.clone()) }