Skip to content

Commit

Permalink
mempool: use buffer-map in getConflicts()
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Aug 12, 2022
1 parent 04f01de commit 432a30d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/mempool/mempool.js
Original file line number Diff line number Diff line change
Expand Up @@ -1759,13 +1759,16 @@ class Mempool extends EventEmitter {

getConflicts(tx) {
const conflicts = [];
const hashes = new BufferSet();

for (const {prevout} of tx.inputs) {
const {hash, index} = prevout;
const conflict = this.getSpent(hash, index);

if (conflict && conflicts.indexOf(conflict) === -1)
if (conflict && !hashes.has(hash)) {
hashes.add(hash);
conflicts.push(conflict);
}
}

return conflicts;
Expand Down

0 comments on commit 432a30d

Please sign in to comment.