diff --git a/README.md b/README.md index 05b4247..7f88220 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ js-libp2p-pubsub [![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) [![](https://img.shields.io/badge/pm-waffle-yellow.svg?style=flat-square)](https://waffle.io/libp2p/js-libp2p-pubsub) -> libp2p-pubsub consists on the base protocol for libp2p pubsub implementations. This module is responsible for registering the protocol in libp2p, as well as all the logic regarding pubsub connections with other peers. +> libp2p-pubsub is the base protocol for libp2p pubsub implementations. This module is responsible for registering the protocol in libp2p, as well as all the logic regarding pubsub connections with other peers. ## Lead Maintainer @@ -38,7 +38,7 @@ js-libp2p-pubsub A pubsub implementation **MUST** override the `_processMessages`, `publish`, `subscribe`, `unsubscribe` and `getTopics` functions. -Other functions, such as `_onPeerConnected`, `_onPeerDisconnected`, `_addPeer`, `_removePeer`, `start` and `stop` may be overwritten if the pubsub implementation needs to add custom logic on them. It is important pointing out that `start` and `stop` **must** call `super`. The `start` function is responsible for registering the pubsub protocol onto the libp2p node, while the `stop` function is responsible for unregistering the pubsub protocol and shutting down every connection +Other functions, such as `_onPeerConnected`, `_onPeerDisconnected`, `_addPeer`, `_removePeer`, `start` and `stop` may be overwritten if the pubsub implementation needs to add custom logic to them. It is important pointing out that `start` and `stop` **must** call `super`. The `start` function is responsible for registering the pubsub protocol onto the libp2p node, while the `stop` function is responsible for unregistering the pubsub protocol and shutting down every connection All the remaining functions **MUST NOT** be overwritten. @@ -83,7 +83,7 @@ The following specified API should be the base API for a pubsub implementation o ### Start -Start the pubsub subsystem. The protocol will be registered to `libp2p`, which will notify about peers being connected and disconnected with the protocol. +Starts the pubsub subsystem. The protocol will be registered to `libp2p`, which will result in pubsub being notified when peers who support the protocol connect/disconnect to `libp2p`. #### `pubsub.start()` @@ -162,7 +162,7 @@ Get the list of topics which the peer is subscribed to. ### Get Peers Subscribed to a topic -Get a list of the peer-ids that are subscribed to one topic. +Get a list of the [PeerId](https://github.com/libp2p/js-peer-id) strings that are subscribed to one topic. #### `pubsub.getPeersSubscribed(topic)` @@ -176,7 +176,7 @@ Get a list of the peer-ids that are subscribed to one topic. | Type | Description | |------|-------------| -| `Array` | Array of base-58 peer id's | +| `Array` | Array of base-58 PeerId's | ### Validate diff --git a/src/index.js b/src/index.js index d671168..d69166c 100644 --- a/src/index.js +++ b/src/index.js @@ -201,14 +201,14 @@ class PubsubBaseProtocol extends EventEmitter { // If strict signing is on and we have no signature, abort if (this.strictSigning && !message.signature) { this.log('Signing required and no signature was present, dropping message:', message) - return Promise.resolve(false) + return false } // Check the message signature if present if (message.signature) { return verifySignature(message) } else { - return Promise.resolve(true) + return true } } diff --git a/test/pubsub.spec.js b/test/pubsub.spec.js index 477ac6c..7a86004 100644 --- a/test/pubsub.spec.js +++ b/test/pubsub.spec.js @@ -41,7 +41,7 @@ describe('pubsub base protocol', () => { expect(sinonMockRegistrar.unregister.calledOnce).to.be.true() }) - it('should not throw to start if already started', async () => { + it('starting should not throw if already started', async () => { await pubsub.start() await pubsub.start() expect(sinonMockRegistrar.register.calledOnce).to.be.true() @@ -64,7 +64,7 @@ describe('pubsub base protocol', () => { }) }) - describe('should handle messages creating and signing', () => { + describe('should handle message creation and signing', () => { let peerInfo let pubsub