Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 58fb802

Browse files
authored
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
1 parent 4bad1c6 commit 58fb802

File tree

1 file changed

+4
-4
lines changed
  • packages/ipfs-core/src/components/stats

1 file changed

+4
-4
lines changed

packages/ipfs-core/src/components/stats/bw.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ function getBandwidthStats (libp2p, opts) {
5353
const { movingAverages, snapshot } = stats
5454

5555
return {
56-
totalIn: BigInt(snapshot.dataReceived.toString()),
57-
totalOut: BigInt(snapshot.dataSent.toString()),
58-
rateIn: BigInt(movingAverages.dataReceived[60000].movingAverage() / 60),
59-
rateOut: BigInt(movingAverages.dataSent[60000].movingAverage() / 60)
56+
totalIn: BigInt(snapshot.dataReceived.integerValue().toString()),
57+
totalOut: BigInt(snapshot.dataSent.integerValue().toString()),
58+
rateIn: BigInt(Math.round(movingAverages.dataReceived[60000].movingAverage() / 60)),
59+
rateOut: BigInt(Math.round(movingAverages.dataSent[60000].movingAverage() / 60))
6060
}
6161
}
6262

0 commit comments

Comments
 (0)