Skip to content

Commit a65c5bc

Browse files
Prabhakar PoudelAlan Shaw
Prabhakar Poudel
authored and
Alan Shaw
committed
docs(swarm local address): add documentation spec for swarm.localAddrs (ipfs#477)
closes ipfs#296 License: MIT Signed-off-by: Prabhakar-Poudel <[email protected]>
1 parent 9b58c39 commit a65c5bc

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

SPEC/SWARM.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
* [swarm.addrs](#swarmaddrs)
44
* [swarm.connect](#swarmconnect)
55
* [swarm.disconnect](#swarmdisconnect)
6+
* [swarm.localAddrs](#swarmlocaladdrs)
67
* [swarm.peers](#swarmpeers)
7-
* [swarm.filters.add](#swarmfiltersadd)
8-
* [swarm.filters.rm](#swarmfiltersrm)
8+
* [swarm.filters.add](#swarmfiltersadd) (not implemented yet)
9+
* [swarm.filters.rm](#swarmfiltersrm) (not implemented yet)
910

1011
#### `swarm.addrs`
1112

@@ -75,6 +76,29 @@ ipfs.swarm.disconnect(addr, function (err) {})
7576

7677
A great source of [examples][] can be found in the tests for this API.
7778

79+
#### `swarm.localAddrs`
80+
81+
> Local addresses this node is listening on.
82+
83+
##### `ipfs.swarm.localAddrs([callback])`
84+
85+
`callback` must follow `function (err, multiAddrs) {}` signature, where `err` is an error if the operation was not successful. `multiAddrs` will be an array of [`MultiAddr`](https://github.com/multiformats/js-multiaddr).
86+
87+
If no `callback` is passed, a promise is returned.
88+
89+
**Example:**
90+
91+
```JavaScript
92+
ipfs.swarm.localAddrs(function (err, multiAddrs) {
93+
if (err) {
94+
throw err
95+
}
96+
console.log(multiAddrs)
97+
})
98+
```
99+
100+
A great source of [examples][] can be found in the tests for this API.
101+
78102
#### `swarm.peers`
79103

80104
> List out the peers that we have connections with.

0 commit comments

Comments
 (0)