From 58fb802a05f7ea44ef595f118130952176f7190d Mon Sep 17 00:00:00 2001 From: Manuel Spagnolo Date: Tue, 27 Jul 2021 11:26:01 +0200 Subject: [PATCH] fix: round bandwidth stats (#3735) Dividing the bandwidth stats sometimes results in a fraction which we cannot convert to a `BigInteger` since it's not an integer... Fixes #3726 --- packages/ipfs-core/src/components/stats/bw.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ipfs-core/src/components/stats/bw.js b/packages/ipfs-core/src/components/stats/bw.js index fae29b608b..3981059848 100644 --- a/packages/ipfs-core/src/components/stats/bw.js +++ b/packages/ipfs-core/src/components/stats/bw.js @@ -53,10 +53,10 @@ function getBandwidthStats (libp2p, opts) { const { movingAverages, snapshot } = stats return { - totalIn: BigInt(snapshot.dataReceived.toString()), - totalOut: BigInt(snapshot.dataSent.toString()), - rateIn: BigInt(movingAverages.dataReceived[60000].movingAverage() / 60), - rateOut: BigInt(movingAverages.dataSent[60000].movingAverage() / 60) + totalIn: BigInt(snapshot.dataReceived.integerValue().toString()), + totalOut: BigInt(snapshot.dataSent.integerValue().toString()), + rateIn: BigInt(Math.round(movingAverages.dataReceived[60000].movingAverage() / 60)), + rateOut: BigInt(Math.round(movingAverages.dataSent[60000].movingAverage() / 60)) } }