Skip to content

Commit 0017037

Browse files
committed
refactor(chain): compute txid once for KeychainTxOutIndex::index_tx
1 parent 639d735 commit 0017037

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

crates/chain/src/keychain/txout_index.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ impl<K: Clone + Ord + Debug> Indexer for KeychainTxOutIndex<K> {
154154

155155
fn index_tx(&mut self, tx: &bitcoin::Transaction) -> Self::ChangeSet {
156156
let mut changeset = ChangeSet::<K>::default();
157+
let txid = tx.compute_txid();
157158
for (op, txout) in tx.output.iter().enumerate() {
158-
changeset.append(self.index_txout(OutPoint::new(tx.compute_txid(), op as u32), txout));
159+
changeset.append(self.index_txout(OutPoint::new(txid, op as u32), txout));
159160
}
160161
changeset
161162
}

0 commit comments

Comments
 (0)