From: 志宇 Date: Thu, 13 Jun 2024 14:56:19 +0000 (+0800) Subject: refactor(chain): compute txid once for `KeychainTxOutIndex::index_tx` X-Git-Tag: v1.0.0-alpha.13~4^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/static/struct.Persist.html?a=commitdiff_plain;h=8dd174479f9719309663ed979a5b4b86aca0a6e9;p=bdk refactor(chain): compute txid once for `KeychainTxOutIndex::index_tx` --- diff --git a/crates/chain/src/keychain/txout_index.rs b/crates/chain/src/keychain/txout_index.rs index 0bdd6c94..cf0f21f8 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 }