Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
  • Loading branch information
vasco-santos and jacobheun committed Oct 21, 2019
1 parent 97bfa5c commit ec808e0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

Expand Down Expand Up @@ -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()`

Expand Down Expand Up @@ -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)`

Expand All @@ -176,7 +176,7 @@ Get a list of the peer-ids that are subscribed to one topic.

| Type | Description |
|------|-------------|
| `Array<string>` | Array of base-58 peer id's |
| `Array<string>` | Array of base-58 PeerId's |

### Validate

Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/pubsub.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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

Expand Down

0 comments on commit ec808e0

Please sign in to comment.