From 6829e67e15cc4cfcf6b6fe6aab13efee315c6476 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sun, 25 Jun 2023 20:38:18 -0400 Subject: [PATCH] Add sanity check for uint32 uid overflow --- backend/src/api/mempool-blocks.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/src/api/mempool-blocks.ts b/backend/src/api/mempool-blocks.ts index c753d2293..ca318bb5d 100644 --- a/backend/src/api/mempool-blocks.ts +++ b/backend/src/api/mempool-blocks.ts @@ -374,6 +374,10 @@ class MempoolBlocks { } public async $rustUpdateBlockTemplates(newMempool: { [txid: string]: MempoolTransactionExtended }, added: MempoolTransactionExtended[], removed: MempoolTransactionExtended[]): Promise { + // sanity check to avoid approaching uint32 uid overflow + if (this.nextUid > 4_000_000_000) { + this.resetRustGbt(); + } if (!this.rustInitialized) { // need to reset the worker await this.$rustMakeBlockTemplates(newMempool, true);