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

Commit

Permalink
feat(swarm): expose PeerInfo for addrs command
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Sep 15, 2016
1 parent 88d6002 commit 077749c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 4 additions & 6 deletions API/swarm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Swarm API

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

`callback` must follow `function (err, addrs) {}` signature, where `err` is an error if the operation was not successful. `addrs` will be an array of multiaddrs.
`callback` must follow `function (err, addrs) {}` signature, where `err` is an error if the operation was not successful. `addrs` will be an array of [`PeerInfo`](https://github.com/libp2p/js-peer-info)s.

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

Expand All @@ -29,7 +29,7 @@ ipfs.swarm.addrs(function (err, addrs) {})

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

Expand All @@ -51,7 +51,7 @@ ipfs.swarm.connect(addr, function (err) {

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

Expand Down Expand Up @@ -111,7 +111,7 @@ ipfs.swarm.filters(function (err, filters) {})

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

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

Expand Down Expand Up @@ -140,5 +140,3 @@ Example:
```JavaScript
ipfs.swarm.filters.rm(filter, function (err) {})
```


5 changes: 4 additions & 1 deletion src/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = (common) => {
it('.connect', (done) => {
ipfsB.id((err, id) => {
expect(err).to.not.exist

const ipfsBAddr = id.addresses[0]
ipfsA.swarm.connect(ipfsBAddr, done)
})
Expand All @@ -62,7 +63,9 @@ module.exports = (common) => {
it('.addrs', (done) => {
ipfsA.swarm.addrs((err, multiaddrs) => {
expect(err).to.not.exist
expect(multiaddrs).to.have.length.above(0)
expect(multiaddrs).to.not.be.empty
expect(multiaddrs).to.be.an('array')
expect(multiaddrs[0].constructor.name).to.be.eql('Peer')
done()
})
})
Expand Down

0 comments on commit 077749c

Please sign in to comment.