From 36bc1db1953cf0bef77076206d530d9acf732b6f Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sat, 22 Jun 2024 04:38:06 +0000 Subject: [PATCH] Fix hardcoded median weight units in calcEffectiveFeeStatistics --- backend/src/api/common.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/api/common.ts b/backend/src/api/common.ts index 9a9f7886b..04f380418 100644 --- a/backend/src/api/common.ts +++ b/backend/src/api/common.ts @@ -904,9 +904,10 @@ export class Common { let medianFee = 0; let medianWeight = 0; - // calculate the "medianFee" as the average fee rate of the middle 10000 weight units of transactions - const leftBound = 1995000; - const rightBound = 2005000; + // calculate the "medianFee" as the average fee rate of the middle 0.25% weight units of transactions + const halfWidth = config.MEMPOOL.BLOCK_WEIGHT_UNITS / 800; + const leftBound = Math.floor((config.MEMPOOL.BLOCK_WEIGHT_UNITS / 2) - halfWidth); + const rightBound = Math.ceil((config.MEMPOOL.BLOCK_WEIGHT_UNITS / 2) + halfWidth); for (let i = 0; i < sortedTxs.length && weightCount < rightBound; i++) { const left = weightCount; const right = weightCount + sortedTxs[i].weight;