From 28de93d0ff4e6c932b805f412e787515bbf45ce2 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Fri, 24 Mar 2023 09:48:08 +0900 Subject: [PATCH] move lazy tx deletion into main loop --- backend/src/api/mempool.ts | 3 +-- backend/src/index.ts | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/api/mempool.ts b/backend/src/api/mempool.ts index db5de82b2..1be1faceb 100644 --- a/backend/src/api/mempool.ts +++ b/backend/src/api/mempool.ts @@ -38,7 +38,6 @@ class Mempool { constructor() { setInterval(this.updateTxPerSecond.bind(this), 1000); - setInterval(this.deleteExpiredTransactions.bind(this), 20000); } /** @@ -256,7 +255,7 @@ class Mempool { } } - private deleteExpiredTransactions() { + public deleteExpiredTransactions() { const now = new Date().getTime(); for (const tx in this.mempoolCache) { const lazyDeleteAt = this.mempoolCache[tx].deleteAfter; diff --git a/backend/src/index.ts b/backend/src/index.ts index ccba83be9..a34ffd21b 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -178,6 +178,7 @@ class Server { logger.debug(msg); } } + memPool.deleteExpiredTransactions(); await blocks.$updateBlocks(); await memPool.$updateMempool(); indexer.$run();