Skip to content

Commit e7347e5

Browse files
authored
fix: parallelize mempool rbf updates (#2328)
1 parent 0b196f0 commit e7347e5

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/datastore/pg-write-store.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,12 @@ export class PgWriteStore extends PgStore {
306306
// by their txs which are now also reorged. We must do this here because the block re-org
307307
// logic is decoupled from the microblock re-org logic so previous balance updates will
308308
// not apply.
309-
await this.updateFtBalancesFromMicroblockReOrg(sql, [
310-
...reorg.markedNonCanonical.microblockHashes,
311-
...reorg.markedCanonical.microblockHashes,
312-
]);
309+
q.enqueue(async () => {
310+
await this.updateFtBalancesFromMicroblockReOrg(sql, [
311+
...reorg.markedNonCanonical.microblockHashes,
312+
...reorg.markedCanonical.microblockHashes,
313+
]);
314+
});
313315
}
314316
if (data.poxSetSigners && data.poxSetSigners.signers) {
315317
const poxSet = data.poxSetSigners;
@@ -341,14 +343,16 @@ export class PgWriteStore extends PgStore {
341343
const mempoolGarbageResults = await this.deleteGarbageCollectedMempoolTxs(sql);
342344
garbageCollectedMempoolTxs = mempoolGarbageResults.deletedTxs;
343345
});
346+
q.enqueue(async () => {
347+
await this.updateReplacedByFeeStatusForTxIds(
348+
sql,
349+
data.txs.map(t => t.tx.tx_id),
350+
false
351+
);
352+
});
344353
await q.done();
345354
}
346355

347-
await this.updateReplacedByFeeStatusForTxIds(
348-
sql,
349-
data.txs.map(t => t.tx.tx_id),
350-
false
351-
);
352356
if (!this.isEventReplay) {
353357
this.debounceMempoolStat();
354358
}

0 commit comments

Comments
 (0)