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

Commit

Permalink
feat(swarm): add swarm.connect + .disconnect + .filters + .filters.ad…
Browse files Browse the repository at this point in the history
…d + filters.rm + .peers
  • Loading branch information
daviddias committed Aug 16, 2016
1 parent 0f24de2 commit f62f648
Showing 1 changed file with 66 additions and 9 deletions.
75 changes: 66 additions & 9 deletions API/swarm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,58 +25,115 @@ ipfs.swarm.addrs(function (err, addrs) {})
##### `Go` **WIP**

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

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

`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful.

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

Example:

```JavaScript
ipfs.swarm.connect(addr, function (err) {
// if no err is present, connection is now open
})
```

#### `disconnect`

> Close a connection on a given address.
##### `Go` **WIP**

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

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

`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.

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

Example:

```JavaScript
ipfs.swarm.disconnect(addr, function (err) {})
```

#### `filters`

> Manipulate address filters
> Display current multiaddr filters
##### `Go` **WIP**

##### `JavaScript` - ipfs.swarm.filters([callback])

`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.

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

Example:

```JavaScript
ipfs.swarm.filters(function (err, filters) {})
```

#### `filters.add`

> Add another filter.
##### `Go` **WIP**

##### `JavaScript` - ipfs.swarm.filters(data, [callback])
##### `JavaScript` - ipfs.swarm.filters.add(filter, [callback])

Where `filter` is of type [multiaddr]()

`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful.

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

Example:

```JavaScript
ipfs.swarm.filters.add(filter, function (err) {})
```

#### `filters.rm`

> Remove a filter
##### `Go` **WIP**

##### `JavaScript` - ipfs.swarm.filters.rm(filter, [callback])

Where `filter` is of type [multiaddr]()

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

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

Example:

```JavaScript
ipfs.swarm.filters.rm(filter, function (err) {})
```

#### `peers`

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

##### `JavaScript` - ipfs.swarm.peers(data, [callback])
##### `JavaScript` - ipfs.swarm.peers([callback])

`callback` must follow `function (err, res) {}` signature, where `err` is an error if the operation was not successful. `res` will be an array of:
`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]().

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

Example:


```JavaScript
ipfs.swarm.peers(function (err, peerInfos) {})
```

0 comments on commit f62f648

Please sign in to comment.