Skip to content

Commit a6ea3b7

Browse files
committed
refactored getLowestPriorityEvictable
1 parent 7239a4e commit a6ea3b7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

yarn-project/p2p/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -663,18 +663,22 @@ export class AztecKVTxPool
663663
* Iterates the priority index in ascending order and skips non-evictable txs.
664664
*/
665665
public async getLowestPriorityEvictable(limit: number): Promise<TxHash[]> {
666-
const result: TxHash[] = [];
666+
const txsToEvict: TxHash[] = [];
667667
if (limit <= 0) {
668-
return result;
668+
return txsToEvict;
669669
}
670+
670671
for await (const txHashStr of this.#pendingTxPriorityToHash.valuesAsync()) {
671-
if (!this.#nonEvictableTxs.has(txHashStr)) {
672-
result.push(TxHash.fromString(txHashStr));
673-
if (result.length >= limit) {
674-
break;
675-
}
672+
if (this.#nonEvictableTxs.has(txHashStr)) {
673+
continue;
674+
}
675+
676+
txsToEvict.push(TxHash.fromString(txHashStr));
677+
if (txsToEvict.length >= limit) {
678+
break;
676679
}
677680
}
678-
return result;
681+
682+
return txsToEvict;
679683
}
680684
}

0 commit comments

Comments
 (0)