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

feat(swarm): expose PeerInfo for addrs command #73

Merged
merged 1 commit into from
Sep 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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