Skip to content

Commit f1bffcc

Browse files
PhilWindlemralj
andcommitted
chore: Removed cache of pending transactions
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. Co-authored-by: Phil Windle <[email protected]> Co-authored-by: mralj <[email protected]>
1 parent 335568e commit f1bffcc

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
@@ -58,9 +58,6 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
5858
/** The cumulative tx size in bytes that the pending txs in the pool take up. */
5959
#pendingTxSize: AztecAsyncSingleton<number>;
6060

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

@@ -113,7 +110,6 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
113110
this.#deletedMinedTxHashes = store.openMap('deletedMinedTxHashes');
114111
this.#blockToDeletedMinedTxHash = store.openMultiMap('blockToDeletedMinedTxHash');
115112

116-
this.#pendingTxs = new Map<string, Tx>();
117113
this.#nonEvictableTxs = new Set<string>();
118114

119115
this.#archivedTxs = archive.openMap('archivedTxs');
@@ -506,20 +502,12 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
506502
* @returns The transaction, if found, 'undefined' otherwise.
507503
*/
508504
private async getPendingTxByHash(txHash: TxHash | string): Promise<Tx | undefined> {
509-
let key;
510505
if (typeof txHash === 'string') {
511-
key = txHash;
512506
txHash = TxHash.fromString(txHash);
513-
} else {
514-
key = txHash.toString();
515507
}
516508

517-
if (this.#pendingTxs.has(key)) {
518-
return this.#pendingTxs.get(key);
519-
}
520509
const tx = await this.getTxByHash(txHash);
521510
if (tx) {
522-
this.#pendingTxs.set(key, tx);
523511
return tx;
524512
}
525513
return undefined;
@@ -750,6 +738,5 @@ export class AztecKVTxPool extends (EventEmitter as new () => TypedEventEmitter<
750738
await this.#pendingTxPriorityToHash.deleteValue(getPendingTxPriority(tx), txHash);
751739
await this.#pendingTxHashToSize.delete(txHash);
752740
await this.#pendingTxHashToHeaderHash.delete(txHash);
753-
this.#pendingTxs.delete(txHash);
754741
}
755742
}

0 commit comments

Comments
 (0)