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

Commit 7737546

Browse files
committed
fix: improve bitswap wantlist and unwant docs
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
1 parent 9f81bcb commit 7737546

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

SPEC/BITSWAP.md

+26-5
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,52 @@
1010
1111
##### `Go` **WIP**
1212

13-
##### `JavaScript` - ipfs.bitswap.unwant(cid)
13+
##### `JavaScript` - ipfs.bitswap.unwant(cid, [callback])
1414

1515
`cid` is a [cid][cid] which can be passed as:
1616

1717
- CID, a CID instance
1818
- String, the base58 encoded version of the multihash
1919

20+
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.
21+
22+
**Example:**
23+
24+
```JavaScript
25+
ipfs.bitswap.unwant('QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu', (err) => {
26+
if (err) throw err
27+
console.log('Done')
28+
})
29+
```
30+
2031
##### `Go` **WIP**
2132

2233
### `bitswap.wantlist`
2334

24-
> Returns the wantlist, optionally limited by peerID
35+
> Returns the wantlist, optionally filtered by peer ID
2536
2637
#### `Go` **WIP**
2738

28-
#### `JavaScript` - ipfs.bitswap.wantlist([peerId])
39+
#### `JavaScript` - ipfs.bitswap.wantlist([peerId], [callback])
40+
41+
`callback` must follow `function (err, list) {}` signature, where `err` is an error if the operation was not successful. `list` is an Object containing the following keys:
42+
43+
- `Keys` An array of objects containing the following keys:
44+
- `/` A string multihash
45+
46+
If no `callback` is passed, a promise is returned.
47+
48+
**Example:**
2949

3050
```JavaScript
3151
ipfs.bitswap.wantlist((err, list) => console.log(list))
3252

33-
//[ { Wantlist object }, ... ]
53+
// { Keys: [{ '/': 'QmHash' }] }
3454

3555
ipfs.bitswap.wantlist(peerId, (err, list) => console.log(list))
3656

37-
//[ { Wantlist object }, ... ]
57+
// { Keys: [{ '/': 'QmHash' }] }
58+
```
3859

3960
#### `bitswap.stat`
4061

0 commit comments

Comments
 (0)