From 001703760164bb1a16a271859d4d7fa21debfaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Thu, 13 Jun 2024 22:56:19 +0800 Subject: [PATCH] refactor(chain): compute txid once for `KeychainTxOutIndex::index_tx` --- crates/chain/src/keychain/txout_index.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/chain/src/keychain/txout_index.rs b/crates/chain/src/keychain/txout_index.rs index 0bdd6c94f0..cf0f21f881 100644 --- a/crates/chain/src/keychain/txout_index.rs +++ b/crates/chain/src/keychain/txout_index.rs @@ -154,8 +154,9 @@ impl Indexer for KeychainTxOutIndex { fn index_tx(&mut self, tx: &bitcoin::Transaction) -> Self::ChangeSet { let mut changeset = ChangeSet::::default(); + let txid = tx.compute_txid(); for (op, txout) in tx.output.iter().enumerate() { - changeset.append(self.index_txout(OutPoint::new(tx.compute_txid(), op as u32), txout)); + changeset.append(self.index_txout(OutPoint::new(txid, op as u32), txout)); } changeset }