Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Latest commit

 

History

History
83 lines (61 loc) · 2.06 KB

BITSWAP.md

File metadata and controls

83 lines (61 loc) · 2.06 KB

Bitswap API

bitswap.wantlist

Returns the wantlist, optionally filtered by peer ID

ipfs.bitswap.wantlist([peerId])

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.

bitswap.stat

Show diagnostic information on the bitswap agent.

ipfs.bitswap.stat()

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:

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.