From 79e44479e9dfddd4c89873ccc03d718990dbc780 Mon Sep 17 00:00:00 2001 From: softsimon Date: Mon, 29 Nov 2021 22:54:13 +0400 Subject: [PATCH] Remodeling how historical fees are stored and presented. fixes #908 --- backend/src/api/statistics.ts | 9 +++---- .../mempool-graph/mempool-graph.component.ts | 24 ++++--------------- .../statistics/statistics.component.html | 17 +++---------- 3 files changed, 10 insertions(+), 40 deletions(-) diff --git a/backend/src/api/statistics.ts b/backend/src/api/statistics.ts index 7f539ef22..6cdfd72e7 100644 --- a/backend/src/api/statistics.ts +++ b/backend/src/api/statistics.ts @@ -85,17 +85,14 @@ class Statistics { 250, 300, 350, 400, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1600, 1800, 2000]; const weightVsizeFees: { [feePerWU: number]: number } = {}; + const lastItem = logFees.length - 1; memPoolArray.forEach((transaction) => { for (let i = 0; i < logFees.length; i++) { if ( - (config.MEMPOOL.NETWORK === 'liquid' - && ((logFees[i] === 2000 && transaction.effectiveFeePerVsize * 10 >= 2000) - || transaction.effectiveFeePerVsize * 10 <= logFees[i])) + (config.MEMPOOL.NETWORK === 'liquid' && (i === lastItem || transaction.effectiveFeePerVsize * 10 < logFees[i + 1])) || - (config.MEMPOOL.NETWORK !== 'liquid' - && ((logFees[i] === 2000 && transaction.effectiveFeePerVsize >= 2000) - || transaction.effectiveFeePerVsize <= logFees[i])) + (config.MEMPOOL.NETWORK !== 'liquid' && (i === lastItem || transaction.effectiveFeePerVsize < logFees[i + 1])) ) { if (weightVsizeFees[logFees[i]]) { weightVsizeFees[logFees[i]] += transaction.vsize; diff --git a/frontend/src/app/components/mempool-graph/mempool-graph.component.ts b/frontend/src/app/components/mempool-graph/mempool-graph.component.ts index d6085b50c..3fd8912fd 100644 --- a/frontend/src/app/components/mempool-graph/mempool-graph.component.ts +++ b/frontend/src/app/components/mempool-graph/mempool-graph.component.ts @@ -90,11 +90,6 @@ export class MempoolGraphComponent implements OnInit, OnChanges { const labels = mempoolStats.map(stats => stats.added); const finalArrayVByte = this.generateArray(mempoolStats); - // Only Liquid has lower than 1 sat/vb transactions - if (this.stateService.network !== 'liquid') { - finalArrayVByte.shift(); - } - return { labels: labels, series: finalArrayVByte @@ -104,10 +99,7 @@ export class MempoolGraphComponent implements OnInit, OnChanges { generateArray(mempoolStats: OptimizedMempoolStats[]) { const finalArray: number[][] = []; let feesArray: number[] = []; - let limitFeesTemplate = this.template === 'advanced' ? 28 : 21; - if (this.stateService.network === 'liquid') { - limitFeesTemplate = this.template === 'advanced' ? 26 : 20; - } + let limitFeesTemplate = this.template === 'advanced' ? 26 : 20; for (let index = limitFeesTemplate; index > -1; index--) { feesArray = []; mempoolStats.forEach((stats) => { @@ -370,18 +362,10 @@ export class MempoolGraphComponent implements OnInit, OnChanges { this.feeLimitIndex = i; } if (feeLevels[i] <= this.limitFee) { - if (i === 0) { - if (this.stateService.network === 'liquid') { - this.feeLevelsOrdered.push('0 - 0.1'); - } else { - this.feeLevelsOrdered.push('0 - 1'); - } + if (this.stateService.network === 'liquid') { + this.feeLevelsOrdered.push(`${(feeLevels[i] / 10).toFixed(1)} - ${(feeLevels[i + 1] / 10).toFixed(1)}`); } else { - if (this.stateService.network === 'liquid') { - this.feeLevelsOrdered.push(`${feeLevels[i - 1] / 10} - ${feeLevels[i] / 10}`); - } else { - this.feeLevelsOrdered.push(`${feeLevels[i - 1]} - ${feeLevels[i]}`); - } + this.feeLevelsOrdered.push(`${feeLevels[i]} - ${feeLevels[i + 1]}`); } } } diff --git a/frontend/src/app/components/statistics/statistics.component.html b/frontend/src/app/components/statistics/statistics.component.html index 682e5a230..1da075a2f 100644 --- a/frontend/src/app/components/statistics/statistics.component.html +++ b/frontend/src/app/components/statistics/statistics.component.html @@ -42,26 +42,15 @@