Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 2.5 KB

STATS.md

File metadata and controls

75 lines (53 loc) · 2.5 KB

Stats API

ipfs.stats.bitswap([options]

Show diagnostic information on the bitswap agent.

Note: stats.bitswap and bitswap.stat can be used interchangeably. See bitswap.stat for more details.

ipfs.stats.repo([options])

Get stats for the currently used repo.

Note: stats.repo and repo.stat can be used interchangeably. See repo.stat for more details.

ipfs.stats.bw([options])

Get IPFS bandwidth information.

Parameters

None

Options

An optional object which may have the following keys:

Name Type Default Description
peer PeerId, CID or String undefined Specifies a peer to print bandwidth for
proto String undefined Specifies a protocol to print bandwidth for
poll boolean undefined Is used to yield bandwidth info at an interval
interval Number undefined The time interval to wait between updating output, if poll is true
timeout Number undefined A timeout in ms
signal AbortSignal undefined Can be used to cancel any long running requests started as a result of this call

Returns

Type Description
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.