From 55d302ea1678fb121148bad5718bda75dfebadd1 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Thu, 11 Jan 2024 23:29:52 +0100 Subject: [PATCH] Only add history estimates beyond mempool depth --- src/server.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/server.tsx b/src/server.tsx index 3e4e275..fdfd147 100644 --- a/src/server.tsx +++ b/src/server.tsx @@ -206,12 +206,15 @@ function calculateFees(mempoolFeeEstimates: MempoolFeeEstimates | null | undefin if (esploraFeeEstimates) { for (const [blockTarget, fee] of Object.entries(esploraFeeEstimates)) { - if (!feeByBlockTarget.hasOwnProperty(blockTarget)) { - const adjustedFee = Math.round(fee * 1000 * feeMultiplier); - if ((!minMempoolFee || adjustedFee < minMempoolFee) && (!minFee || adjustedFee > minFee)) { - feeByBlockTarget[blockTarget] = adjustedFee; - } - } + const blockTargetInt = parseInt(blockTarget); + const adjustedFee = Math.round(fee * 1000 * feeMultiplier); + + if (feeByBlockTarget.hasOwnProperty(blockTarget)) continue; + if (minMempoolFee && adjustedFee >= minMempoolFee) continue; + if (minFee && adjustedFee <= minFee) continue; + if (blockTargetInt <= mempoolDepth) continue; + + feeByBlockTarget[blockTarget] = adjustedFee; } }