Skip to content

Commit fe51c73

Browse files
authored
chore: Removed cache of pending transactions (#19275)
We currently cache all pending transactions when they are read from the tx poo database. This causes significant memory usage however and is unnecessary. This PR removes this cache.
2 parents 3fce3ea + ed94838 commit fe51c73

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ export class AztecKVTxPool
5757

5858
#feePayerToTxHash: AztecAsyncMultiMap<string, string>;
5959

60-
/** In-memory mapping of pending tx hashes to the hydrated pending tx in the pool. */
61-
#pendingTxs: Map<string, Tx>;
62-
6360
/** In-memory set of txs that should not be evicted from the pool. */
6461
#nonEvictableTxs: Set<string>;
6562

@@ -124,7 +121,6 @@ export class AztecKVTxPool
124121
this.#historicalHeaderToTxHash = store.openMultiMap('historicalHeaderToPendingTxHash');
125122
this.#feePayerToTxHash = store.openMultiMap('feePayerToPendingTxHash');
126123

127-
this.#pendingTxs = new Map<string, Tx>();
128124
this.#nonEvictableTxs = new Set<string>();
129125

130126
this.#archivedTxs = archive.openMap('archivedTxs');
@@ -576,20 +572,12 @@ export class AztecKVTxPool
576572
* @returns The transaction, if found, 'undefined' otherwise.
577573
*/
578574
private async getPendingTxByHash(txHash: TxHash | string): Promise<Tx | undefined> {
579-
let key;
580575
if (typeof txHash === 'string') {
581-
key = txHash;
582576
txHash = TxHash.fromString(txHash);
583-
} else {
584-
key = txHash.toString();
585577
}
586578

587-
if (this.#pendingTxs.has(key)) {
588-
return this.#pendingTxs.get(key);
589-
}
590579
const tx = await this.getTxByHash(txHash);
591580
if (tx) {
592-
this.#pendingTxs.set(key, tx);
593581
return tx;
594582
}
595583
return undefined;
@@ -664,7 +652,6 @@ export class AztecKVTxPool
664652
// Assumes being called within a DB transaction
665653
private async removePendingTxIndicesInDbTx(tx: Tx, txHash: string): Promise<void> {
666654
await this.#pendingTxPriorityToHash.deleteValue(getPendingTxPriority(tx), txHash);
667-
this.#pendingTxs.delete(txHash);
668655
await this.#historicalHeaderToTxHash.deleteValue(
669656
(await tx.data.constants.anchorBlockHeader.hash()).toString(),
670657
txHash,

0 commit comments

Comments
 (0)