Stats API
January 23, 2020 ยท View on GitHub
stats.bitswap
Show diagnostic information on the bitswap agent.
Note: stats.bitswap and bitswap.stat can be used interchangeably. See bitswap.stat for more details.
stats.repo
Get stats for the currently used repo.
Note: stats.repo and repo.stat can be used interchangeably. See repo.stat for more details.
stats.bw
Get IPFS bandwidth information.
ipfs.stats.bw([options])
Where:
optionsis an optional object that might contain the following keys:peerspecifies a peer to print bandwidth for.protospecifies a protocol to print bandwidth for.pollis used to yield bandwidth info at an interval.intervalis the time interval to wait between updating output, ifpollistrue.
Returns
| Type | Description |
|---|---|
AsyncIterable<Object> | An async iterable that yields IPFS bandwidth information |
Each yielded object contains the following keys:
totalIn- is a BigNumber Int, in bytes.totalOut- is a BigNumber Int, in bytes.rateIn- is a BigNumber Int, in bytes.rateOut- is a BigNumber Int, in bytes.
Example:
for await (const stats of ipfs.stats.bw()) {
console.log(stats)
}
// { totalIn: BigNumber {...},
// totalOut: BigNumber {...},
// rateIn: BigNumber {...},
// rateOut: BigNumber {...} }
A great source of examples can be found in the tests for this API.