Skip to content

Commit

Permalink
chore: change readme
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Jul 27, 2020
1 parent b668c8a commit 7e3c541
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LIBP2P.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ If the discovery service is disabled, the rendezvous API also allows users to di

When a libp2p node running the rendezvous protocol is stopping, it will unregister from all the namespaces previously registered.

In the event of a rendezvous client getting connected to a second rendezvous server, it will propagate its registrations to it. The rendezvous server will aso clean its registrations for a peer when it is not connected with it anymore.
In the event of a rendezvous client getting connected to a second rendezvous server, it will propagate its registrations to it. The rendezvous server will also clean its registrations for a peer when it is not connected with it anymore.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ See https://github.com/libp2p/specs/tree/master/rendezvous for more details

[Vasco Santos](https://github.com/vasco-santos).

## Usage

```js
const Libp2p = require('libp2p')
const Rendezvous = require('libp2p-rendezvous')

const libp2p = await Libp2p.create({
// check on js-libp2p repo the options to provide
})
const rendezvous = new Rendezvous({ libp2p }) // Set other options below

await node.start()
rendezvous.start()

// ...

rendezvous.stop()
await node.stop()
```

## API

### constructor
Expand Down
1 change: 1 addition & 0 deletions src/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Discovery extends EventEmitter {
* @returns {void}
*/
stop () {
this.removeAllListeners()
clearInterval(this._interval)
this._interval = null
}
Expand Down
1 change: 1 addition & 0 deletions test/discovery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ describe('rendezvous discovery', () => {
await delay(1000)

peers[1].rendezvous.discovery.removeAllListeners()
peers[1].rendezvous.discovery.stop()
})
})

Expand Down
2 changes: 2 additions & 0 deletions test/server.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,7 @@ describe('rendezvous server', () => {

expect(rServer.nsRegistrations.get(testNamespace).size).to.eql(0)
expect(rServer.cookieRegistrations.get(cookie)).to.not.exist()

rServer.stop()
})
})

0 comments on commit 7e3c541

Please sign in to comment.