Skip to content

Commit

Permalink
fixed stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunkar committed Jan 24, 2025
1 parent bb55e12 commit 5dbd1fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions yarn-project/p2p/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,17 @@ export class AztecKVTxPool implements TxPool {
* @param txs - An array of txs to be added to the pool.
* @returns Empty promise.
*/
public addTxs(txs: Tx[]): Promise<void> {
public async addTxs(txs: Tx[]): Promise<void> {
const hashesAndStats = await Promise.all(
txs.map(async tx => ({ txHash: await tx.getTxHash(), txStats: await tx.getStats() })),
);
return this.#store.transaction(() => {
let pendingCount = 0;
for (const tx of txs) {
const txHash = tx.getTxHash();
txs.forEach((tx, i) => {
const { txHash, txStats } = hashesAndStats[i];
this.#log.verbose(`Adding tx ${txHash.toString()} to pool`, {
eventName: 'tx-added-to-pool',
...tx.getStats(),
...txStats,
} satisfies TxAddedToPoolStats);

const key = txHash.toString();
Expand All @@ -193,7 +196,7 @@ export class AztecKVTxPool implements TxPool {
void this.#pendingTxPriorityToHash.set(getPendingTxPriority(tx), key);
this.#metrics.recordSize(tx);
}
}
});

this.#metrics.recordAddedObjects(pendingCount, 'pending');
});
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/p2p/src/mem_pools/tx_pool/memory_tx_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class InMemoryTxPool implements TxPool {
const txHash = await tx.getTxHash();
this.log.verbose(`Adding tx ${txHash.toString()} to pool`, {
eventName: 'tx-added-to-pool',
...tx.getStats(),
...(await tx.getStats()),
} satisfies TxAddedToPoolStats);

const key = txHash.toBigInt();
Expand Down

0 comments on commit 5dbd1fd

Please sign in to comment.