From d59cda2e81d1e1d388d0236feac673bd82184982 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Tue, 13 Feb 2024 13:56:42 +0000 Subject: [PATCH] Fix float rounding --- src/server.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/server.tsx b/src/server.tsx index 3406834..e5963be 100644 --- a/src/server.tsx +++ b/src/server.tsx @@ -81,12 +81,6 @@ function getValueFromFulfilledPromise(result: PromiseSettledResult) { return result && result.status === "fulfilled" && result.value ? result.value : null; } -function customRound(number: number, decimalPlaces: number): number { - const factor: number = Math.pow(10, decimalPlaces); - const rounded: number = Math.round(number * factor) / factor; - return rounded; -} - // NOTE: fetch signal abortcontroller does not work on Bun. // See https://github.com/oven-sh/bun/issues/2489 async function fetchWithTimeout(url: string, timeout: number = TIMEOUT): Promise { @@ -235,7 +229,7 @@ async function fetchBitcoindFees() : Promise { var feeRate = response[i].result?.feerate; if (feeRate) { // convert the returned value to satoshis, as it's currently returned in BTC. - const satPerKB = customRound(feeRate, 1e8); + const satPerKB : number = feeRate * 1e8; result[target] = applyFeeMultiplier(satPerKB); } else { console.error(`Failed to fetch fee estimate from bitcoind for confirmation target ${target}`, response[i].result?.errors);