This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 6 files changed +18
-18
lines changed
interface-ipfs-core/src/stats
ipfs-core/src/components/stats
ipfs-core-types/src/stats
ipfs-http-client/src/stats
ipfs-http-server/src/api/resources
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:
51
51
52
52
- ` totalIn ` - is a [ BigInt] [ bigNumber ] , in bytes.
53
53
- ` 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.
56
56
57
57
### Example
58
58
@@ -62,8 +62,8 @@ for await (const stats of ipfs.stats.bw()) {
62
62
}
63
63
// { totalIn: BigInt {...},
64
64
// totalOut: BigInt {...},
65
- // rateIn: BigInt {...},
66
- // rateOut: BigInt {...} }
65
+ // rateIn: number {...},
66
+ // rateOut: number {...} }
67
67
```
68
68
69
69
A 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) => {
50
50
expect ( stats ) . to . have . a . property ( 'rateOut' )
51
51
expect ( isBigInt ( stats . totalIn ) ) . to . eql ( true )
52
52
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' )
55
55
}
56
56
57
57
/**
Original file line number Diff line number Diff line change @@ -22,6 +22,6 @@ export interface BWOptions extends AbortOptions {
22
22
export interface BWResult {
23
23
totalIn : bigint
24
24
totalOut : bigint
25
- rateIn : bigint
26
- rateOut : bigint
25
+ rateIn : number
26
+ rateOut : number
27
27
}
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ const withTimeoutOption = require('ipfs-core-utils/src/with-timeout-option')
14
14
* @typedef {Object } BandwidthInfo
15
15
* @property {bigint } totalIn
16
16
* @property {bigint } totalOut
17
- * @property {bigint } rateIn
18
- * @property {bigint } rateOut
17
+ * @property {number } rateIn
18
+ * @property {number } rateOut
19
19
*
20
20
* @typedef {import('libp2p') } libp2p
21
21
* @typedef {import('peer-id') } PeerId
@@ -45,8 +45,8 @@ function getBandwidthStats (libp2p, opts) {
45
45
return {
46
46
totalIn : BigInt ( 0 ) ,
47
47
totalOut : BigInt ( 0 ) ,
48
- rateIn : BigInt ( 0 ) ,
49
- rateOut : BigInt ( 0 )
48
+ rateIn : 0.0 ,
49
+ rateOut : 0.0
50
50
}
51
51
}
52
52
@@ -55,8 +55,8 @@ function getBandwidthStats (libp2p, opts) {
55
55
return {
56
56
totalIn : BigInt ( snapshot . dataReceived . integerValue ( ) . toString ( ) ) ,
57
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 ) )
58
+ rateIn : movingAverages . dataReceived [ 60000 ] . movingAverage ( ) / 60 ,
59
+ rateOut : movingAverages . dataSent [ 60000 ] . movingAverage ( ) / 60
60
60
}
61
61
}
62
62
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ module.exports = configure(api => {
21
21
transform : ( stats ) => ( {
22
22
totalIn : BigInt ( stats . TotalIn ) ,
23
23
totalOut : BigInt ( stats . TotalOut ) ,
24
- rateIn : BigInt ( stats . RateIn ) ,
25
- rateOut : BigInt ( stats . RateOut )
24
+ rateIn : parseFloat ( stats . RateIn ) ,
25
+ rateOut : parseFloat ( stats . RateOut )
26
26
} )
27
27
} )
28
28
Original file line number Diff line number Diff line change @@ -61,8 +61,8 @@ exports.bw = {
61
61
yield * map ( source , stat => ( {
62
62
TotalIn : stat . totalIn . toString ( ) ,
63
63
TotalOut : stat . totalOut . toString ( ) ,
64
- RateIn : stat . rateIn . toString ( ) ,
65
- RateOut : stat . rateOut . toString ( )
64
+ RateIn : stat . rateIn ,
65
+ RateOut : stat . rateOut
66
66
} ) )
67
67
}
68
68
) )
You can’t perform that action at this time.
0 commit comments