From 6ada839282c53f2e8f2324872c7dc4355b1136cc Mon Sep 17 00:00:00 2001 From: Mononaut Date: Wed, 23 Nov 2022 19:32:14 +0900 Subject: [PATCH] reduce forensics throttle delay from 100ms to 20ms --- backend/src/tasks/lightning/forensics.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/tasks/lightning/forensics.service.ts b/backend/src/tasks/lightning/forensics.service.ts index 5d77aee97..9b999fca1 100644 --- a/backend/src/tasks/lightning/forensics.service.ts +++ b/backend/src/tasks/lightning/forensics.service.ts @@ -6,6 +6,8 @@ import config from '../../config'; import { IEsploraApi } from '../../api/bitcoin/esplora-api.interface'; import { Common } from '../../api/common'; +const throttleDelay = 20; //ms + class ForensicsService { loggerTimer = 0; closedChannelsScanBlock = 0; @@ -85,7 +87,7 @@ class ForensicsService { let outspends: IEsploraApi.Outspend[] | undefined; try { outspends = await bitcoinApi.$getOutspends(channel.closing_transaction_id); - await Common.sleep$(100); + await Common.sleep$(throttleDelay); } catch (e) { logger.err(`Failed to call ${config.ESPLORA.REST_API_URL + '/tx/' + channel.closing_transaction_id + '/outspends'}. Reason ${e instanceof Error ? e.message : e}`); continue; @@ -97,7 +99,7 @@ class ForensicsService { if (!spendingTx) { try { spendingTx = await bitcoinApi.$getRawTransaction(outspend.txid); - await Common.sleep$(100); + await Common.sleep$(throttleDelay); this.txCache[outspend.txid] = spendingTx; } catch (e) { logger.err(`Failed to call ${config.ESPLORA.REST_API_URL + '/tx/' + outspend.txid}. Reason ${e instanceof Error ? e.message : e}`); @@ -126,7 +128,7 @@ class ForensicsService { if (!closingTx) { try { closingTx = await bitcoinApi.$getRawTransaction(channel.closing_transaction_id); - await Common.sleep$(100); + await Common.sleep$(throttleDelay); this.txCache[channel.closing_transaction_id] = closingTx; } catch (e) { logger.err(`Failed to call ${config.ESPLORA.REST_API_URL + '/tx/' + channel.closing_transaction_id}. Reason ${e instanceof Error ? e.message : e}`);