From 2be18fe17975da7fe4c18e352ce25cec3cec1026 Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Wed, 9 Mar 2022 17:38:37 +0100 Subject: [PATCH] improve testnet block time estimations --- .../mempool-blocks/mempool-blocks.component.html | 2 +- .../mempool-blocks/mempool-blocks.component.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.html b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.html index 112b35df2..007916cfd 100644 --- a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.html +++ b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.html @@ -26,7 +26,7 @@ - + diff --git a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts index 05735c0be..c03325cfe 100644 --- a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts +++ b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.ts @@ -33,6 +33,7 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy { networkSubscription: Subscription; network = ''; now = new Date().getTime(); + timeOffset = 0; showMiningInfo = false; blockWidth = 125; @@ -146,6 +147,15 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy { timeAvgMins += Math.abs(timeAvgDiff); } + // testnet difficulty is set to 1 after 20 minutes of no blockSize + // therefore the time between blocks will always be below 20 minutes (1200s) + if (this.stateService.network === 'testnet' && now - block.timestamp + timeAvgMins * 60 > 1200) { + this.timeOffset = -Math.min(now - block.timestamp, 1200) * 1000; + timeAvgMins = 20; + } else { + this.timeOffset = 0; + } + return timeAvgMins * 60 * 1000; }) );