Returns the wantlist, optionally filtered by peer ID
Returns
Type | Description |
---|---|
Promise<CID[]> |
An array of CIDs currently in the wantlist |
Example:
const list = await ipfs.bitswap.wantlist()
console.log(list)
// [ CID('QmHash') ]
const list2 = await ipfs.bitswap.wantlist(peerId)
console.log(list2)
// [ CID('QmHash') ]
A great source of examples can be found in the tests for this API.
Show diagnostic information on the bitswap agent.
Note: bitswap.stat
and stats.bitswap
can be used interchangeably.
Returns
Type | Description |
---|---|
Promise<Object> |
An object that contains information about the bitswap agent |
The returned object contains the following keys:
provideBufLen
is an integer.wantlist
(array of CIDs)peers
(array of peer IDs as Strings)blocksReceived
is a BigNumber IntdataReceived
is a BigNumber IntblocksSent
is a BigNumber IntdataSent
is a BigNumber IntdupBlksReceived
is a BigNumber IntdupDataReceived
is a BigNumber Int
Example:
const stats = await ipfs.bitswap.stat()
console.log(stats)
// {
// provideBufLen: 0,
// wantlist: [ CID('QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM') ],
// peers:
// [ 'QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM',
// 'QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu',
// 'QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd' ],
// blocksReceived: 0,
// dataReceived: 0,
// blocksSent: 0,
// dataSent: 0,
// dupBlksReceived: 0,
// dupDataReceived: 0
// }
A great source of examples can be found in the tests for this API.