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

Commit

Permalink
fix: round bandwidth stats (#3735)
Browse files Browse the repository at this point in the history
Dividing the bandwidth stats sometimes results in a fraction which we cannot
convert to a `BigInteger` since it's not an integer...

Fixes #3726
  • Loading branch information
shikaan committed Jul 27, 2021
1 parent 4bad1c6 commit 58fb802
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ipfs-core/src/components/stats/bw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 58fb802

Please sign in to comment.