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:

  • options is an optional object that might contain the following keys:
    • peer specifies a peer to print bandwidth for.
    • proto specifies a protocol to print bandwidth for.
    • poll is used to yield bandwidth info at an interval.
    • interval is the time interval to wait between updating output, if poll is true.

Returns

TypeDescription
AsyncIterable<Object>An async iterable that yields IPFS bandwidth information

Each yielded object contains the following keys:

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.