mirror of
https://github.com/mempool/mempool.git
synced 2025-06-13 10:21:11 +02:00
reduce forensics throttle delay from 100ms to 20ms
This commit is contained in:
parent
7de068368c
commit
6ada839282
@ -6,6 +6,8 @@ import config from '../../config';
|
|||||||
import { IEsploraApi } from '../../api/bitcoin/esplora-api.interface';
|
import { IEsploraApi } from '../../api/bitcoin/esplora-api.interface';
|
||||||
import { Common } from '../../api/common';
|
import { Common } from '../../api/common';
|
||||||
|
|
||||||
|
const throttleDelay = 20; //ms
|
||||||
|
|
||||||
class ForensicsService {
|
class ForensicsService {
|
||||||
loggerTimer = 0;
|
loggerTimer = 0;
|
||||||
closedChannelsScanBlock = 0;
|
closedChannelsScanBlock = 0;
|
||||||
@ -85,7 +87,7 @@ class ForensicsService {
|
|||||||
let outspends: IEsploraApi.Outspend[] | undefined;
|
let outspends: IEsploraApi.Outspend[] | undefined;
|
||||||
try {
|
try {
|
||||||
outspends = await bitcoinApi.$getOutspends(channel.closing_transaction_id);
|
outspends = await bitcoinApi.$getOutspends(channel.closing_transaction_id);
|
||||||
await Common.sleep$(100);
|
await Common.sleep$(throttleDelay);
|
||||||
} catch (e) {
|
} 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}`);
|
logger.err(`Failed to call ${config.ESPLORA.REST_API_URL + '/tx/' + channel.closing_transaction_id + '/outspends'}. Reason ${e instanceof Error ? e.message : e}`);
|
||||||
continue;
|
continue;
|
||||||
@ -97,7 +99,7 @@ class ForensicsService {
|
|||||||
if (!spendingTx) {
|
if (!spendingTx) {
|
||||||
try {
|
try {
|
||||||
spendingTx = await bitcoinApi.$getRawTransaction(outspend.txid);
|
spendingTx = await bitcoinApi.$getRawTransaction(outspend.txid);
|
||||||
await Common.sleep$(100);
|
await Common.sleep$(throttleDelay);
|
||||||
this.txCache[outspend.txid] = spendingTx;
|
this.txCache[outspend.txid] = spendingTx;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err(`Failed to call ${config.ESPLORA.REST_API_URL + '/tx/' + outspend.txid}. Reason ${e instanceof Error ? e.message : 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) {
|
if (!closingTx) {
|
||||||
try {
|
try {
|
||||||
closingTx = await bitcoinApi.$getRawTransaction(channel.closing_transaction_id);
|
closingTx = await bitcoinApi.$getRawTransaction(channel.closing_transaction_id);
|
||||||
await Common.sleep$(100);
|
await Common.sleep$(throttleDelay);
|
||||||
this.txCache[channel.closing_transaction_id] = closingTx;
|
this.txCache[channel.closing_transaction_id] = closingTx;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err(`Failed to call ${config.ESPLORA.REST_API_URL + '/tx/' + channel.closing_transaction_id}. Reason ${e instanceof Error ? e.message : e}`);
|
logger.err(`Failed to call ${config.ESPLORA.REST_API_URL + '/tx/' + channel.closing_transaction_id}. Reason ${e instanceof Error ? e.message : e}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user