File tree Expand file tree Collapse file tree 6 files changed +18
-18
lines changed
interface-ipfs-core/src/stats
ipfs-core-types/src/stats
ipfs-core/src/components/stats
ipfs-http-client/src/stats
ipfs-http-server/src/api/resources Expand file tree Collapse file tree 6 files changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -51,8 +51,8 @@ Each yielded object contains the following keys:
5151
5252- ` totalIn ` - is a [ BigInt] [ bigNumber ] , in bytes.
5353- ` totalOut ` - is a [ BigInt] [ bigNumber ] , in bytes.
54- - ` rateIn ` - is a [ BigInt ] [ bigNumber ] , in bytes.
55- - ` rateOut ` - is a [ BigInt ] [ bigNumber ] , in bytes.
54+ - ` rateIn ` - is a ` float ` , in bytes.
55+ - ` rateOut ` - is a ` float ` , in bytes.
5656
5757### Example
5858
@@ -62,8 +62,8 @@ for await (const stats of ipfs.stats.bw()) {
6262}
6363// { totalIn: BigInt {...},
6464// totalOut: BigInt {...},
65- // rateIn: BigInt {...},
66- // rateOut: BigInt {...} }
65+ // rateIn: number {...},
66+ // rateOut: number {...} }
6767```
6868
6969A great source of [ examples] [ ] can be found in the tests for this API.
Original file line number Diff line number Diff line change @@ -50,8 +50,8 @@ exports.expectIsBandwidth = (err, stats) => {
5050 expect ( stats ) . to . have . a . property ( 'rateOut' )
5151 expect ( isBigInt ( stats . totalIn ) ) . to . eql ( true )
5252 expect ( isBigInt ( stats . totalOut ) ) . to . eql ( true )
53- expect ( isBigInt ( stats . rateIn ) ) . to . eql ( true )
54- expect ( isBigInt ( stats . rateOut ) ) . to . eql ( true )
53+ expect ( stats . rateIn ) . to . be . a ( 'number' )
54+ expect ( stats . rateOut ) . to . be . a ( 'number' )
5555}
5656
5757/**
Original file line number Diff line number Diff line change @@ -22,6 +22,6 @@ export interface BWOptions extends AbortOptions {
2222export interface BWResult {
2323 totalIn : bigint
2424 totalOut : bigint
25- rateIn : bigint
26- rateOut : bigint
25+ rateIn : number
26+ rateOut : number
2727}
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ const withTimeoutOption = require('ipfs-core-utils/src/with-timeout-option')
1414 * @typedef {Object } BandwidthInfo
1515 * @property {bigint } totalIn
1616 * @property {bigint } totalOut
17- * @property {bigint } rateIn
18- * @property {bigint } rateOut
17+ * @property {number } rateIn
18+ * @property {number } rateOut
1919 *
2020 * @typedef {import('libp2p') } libp2p
2121 * @typedef {import('peer-id') } PeerId
@@ -45,8 +45,8 @@ function getBandwidthStats (libp2p, opts) {
4545 return {
4646 totalIn : BigInt ( 0 ) ,
4747 totalOut : BigInt ( 0 ) ,
48- rateIn : BigInt ( 0 ) ,
49- rateOut : BigInt ( 0 )
48+ rateIn : 0.0 ,
49+ rateOut : 0.0
5050 }
5151 }
5252
@@ -55,8 +55,8 @@ function getBandwidthStats (libp2p, opts) {
5555 return {
5656 totalIn : BigInt ( snapshot . dataReceived . integerValue ( ) . toString ( ) ) ,
5757 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 ) )
58+ rateIn : movingAverages . dataReceived [ 60000 ] . movingAverage ( ) / 60 ,
59+ rateOut : movingAverages . dataSent [ 60000 ] . movingAverage ( ) / 60
6060 }
6161}
6262
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ module.exports = configure(api => {
2121 transform : ( stats ) => ( {
2222 totalIn : BigInt ( stats . TotalIn ) ,
2323 totalOut : BigInt ( stats . TotalOut ) ,
24- rateIn : BigInt ( stats . RateIn ) ,
25- rateOut : BigInt ( stats . RateOut )
24+ rateIn : parseFloat ( stats . RateIn ) ,
25+ rateOut : parseFloat ( stats . RateOut )
2626 } )
2727 } )
2828
Original file line number Diff line number Diff line change @@ -61,8 +61,8 @@ exports.bw = {
6161 yield * map ( source , stat => ( {
6262 TotalIn : stat . totalIn . toString ( ) ,
6363 TotalOut : stat . totalOut . toString ( ) ,
64- RateIn : stat . rateIn . toString ( ) ,
65- RateOut : stat . rateOut . toString ( )
64+ RateIn : stat . rateIn ,
65+ RateOut : stat . rateOut
6666 } ) )
6767 }
6868 ) )
You can’t perform that action at this time.
0 commit comments