refactor(chain): compute txid once for KeychainTxOutIndex::index_tx

This commit is contained in:
志宇 2024-06-13 22:56:19 +08:00
parent 639d735ca0
commit 8dd174479f
No known key found for this signature in database
GPG Key ID: F6345C9837C2BDE8

View File

@ -154,8 +154,9 @@ impl<K: Clone + Ord + Debug> Indexer for KeychainTxOutIndex<K> {
fn index_tx(&mut self, tx: &bitcoin::Transaction) -> Self::ChangeSet {
let mut changeset = ChangeSet::<K>::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
}