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

Commit f62f648

Browse files
committed
feat(swarm): add swarm.connect + .disconnect + .filters + .filters.add + filters.rm + .peers
1 parent 0f24de2 commit f62f648

File tree

1 file changed

+66
-9
lines changed

1 file changed

+66
-9
lines changed

API/swarm/README.md

+66-9
Original file line numberDiff line numberDiff line change
@@ -25,58 +25,115 @@ ipfs.swarm.addrs(function (err, addrs) {})
2525
2626
##### `Go` **WIP**
2727

28-
##### `JavaScript` - ipfs.swarm.SOMETHING(data, [callback])
28+
##### `JavaScript` - ipfs.swarm.connect(addr, [callback])
2929

30-
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:
30+
Where `addr` is of type [multiaddr](https://github.com/multiformats/js-multiaddr)
31+
32+
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful.
3133

3234
If no `callback` is passed, a promise is returned.
3335

3436
Example:
3537

38+
```JavaScript
39+
ipfs.swarm.connect(addr, function (err) {
40+
// if no err is present, connection is now open
41+
})
42+
```
3643

3744
#### `disconnect`
3845

3946
> Close a connection on a given address.
4047
4148
##### `Go` **WIP**
4249

43-
##### `JavaScript` - ipfs.swarm.SOMETHING(data, [callback])
50+
##### `JavaScript` - ipfs.swarm.disconnect(addr, [callback])
4451

45-
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:
52+
Where `addr` is of type [multiaddr](https://github.com/multiformats/js-multiaddr)
53+
54+
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.
4655

4756
If no `callback` is passed, a promise is returned.
4857

4958
Example:
5059

60+
```JavaScript
61+
ipfs.swarm.disconnect(addr, function (err) {})
62+
```
5163

5264
#### `filters`
5365

54-
> Manipulate address filters
66+
> Display current multiaddr filters
67+
68+
##### `Go` **WIP**
69+
70+
##### `JavaScript` - ipfs.swarm.filters([callback])
71+
72+
`callback` must follow `function (err, filters) {}` signature, where `err` is an error if the operation was not successful. `filters` is an array of multiaddrs that represent the filters being applied.
73+
74+
If no `callback` is passed, a promise is returned.
75+
76+
Example:
77+
78+
```JavaScript
79+
ipfs.swarm.filters(function (err, filters) {})
80+
```
81+
82+
#### `filters.add`
83+
84+
> Add another filter.
5585
5686
##### `Go` **WIP**
5787

58-
##### `JavaScript` - ipfs.swarm.filters(data, [callback])
88+
##### `JavaScript` - ipfs.swarm.filters.add(filter, [callback])
89+
90+
Where `filter` is of type [multiaddr]()
91+
92+
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.
93+
94+
If no `callback` is passed, a promise is returned.
95+
96+
Example:
97+
98+
```JavaScript
99+
ipfs.swarm.filters.add(filter, function (err) {})
100+
```
101+
102+
#### `filters.rm`
103+
104+
> Remove a filter
105+
106+
##### `Go` **WIP**
107+
108+
##### `JavaScript` - ipfs.swarm.filters.rm(filter, [callback])
109+
110+
Where `filter` is of type [multiaddr]()
59111

60112
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:
61113

62114
If no `callback` is passed, a promise is returned.
63115

64116
Example:
65117

118+
```JavaScript
119+
ipfs.swarm.filters.rm(filter, function (err) {})
120+
```
66121

67122
#### `peers`
68123

69124
> List out the peers that we have connections with.
70125
71126
##### `Go` **WIP**
72127

73-
##### `JavaScript` - ipfs.swarm.peers(data, [callback])
128+
##### `JavaScript` - ipfs.swarm.peers([callback])
74129

75-
`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:
130+
`callback` must follow `function (err, peerInfos) {}` signature, where `err` is an error if the operation was not successful. `peerInfos` will be an array of [PeerInfo]().
76131

77132
If no `callback` is passed, a promise is returned.
78133

79134
Example:
80135

81-
136+
```JavaScript
137+
ipfs.swarm.peers(function (err, peerInfos) {})
138+
```
82139

0 commit comments

Comments
 (0)