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

Commit ec808e0

Browse files
chore: apply suggestions from code review
Co-Authored-By: Jacob Heun <[email protected]>
1 parent 97bfa5c commit ec808e0

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ js-libp2p-pubsub
1212
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
1313
[![](https://img.shields.io/badge/pm-waffle-yellow.svg?style=flat-square)](https://waffle.io/libp2p/js-libp2p-pubsub)
1414

15-
> 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.
15+
> 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.
1616
1717
## Lead Maintainer
1818

@@ -38,7 +38,7 @@ js-libp2p-pubsub
3838

3939
A pubsub implementation **MUST** override the `_processMessages`, `publish`, `subscribe`, `unsubscribe` and `getTopics` functions.
4040

41-
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
41+
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
4242

4343
All the remaining functions **MUST NOT** be overwritten.
4444

@@ -83,7 +83,7 @@ The following specified API should be the base API for a pubsub implementation o
8383

8484
### Start
8585

86-
Start the pubsub subsystem. The protocol will be registered to `libp2p`, which will notify about peers being connected and disconnected with the protocol.
86+
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`.
8787

8888
#### `pubsub.start()`
8989

@@ -162,7 +162,7 @@ Get the list of topics which the peer is subscribed to.
162162

163163
### Get Peers Subscribed to a topic
164164

165-
Get a list of the peer-ids that are subscribed to one topic.
165+
Get a list of the [PeerId](https://github.com/libp2p/js-peer-id) strings that are subscribed to one topic.
166166

167167
#### `pubsub.getPeersSubscribed(topic)`
168168

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

177177
| Type | Description |
178178
|------|-------------|
179-
| `Array<string>` | Array of base-58 peer id's |
179+
| `Array<string>` | Array of base-58 PeerId's |
180180

181181
### Validate
182182

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ class PubsubBaseProtocol extends EventEmitter {
201201
// If strict signing is on and we have no signature, abort
202202
if (this.strictSigning && !message.signature) {
203203
this.log('Signing required and no signature was present, dropping message:', message)
204-
return Promise.resolve(false)
204+
return false
205205
}
206206

207207
// Check the message signature if present
208208
if (message.signature) {
209209
return verifySignature(message)
210210
} else {
211-
return Promise.resolve(true)
211+
return true
212212
}
213213
}
214214

test/pubsub.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('pubsub base protocol', () => {
4141
expect(sinonMockRegistrar.unregister.calledOnce).to.be.true()
4242
})
4343

44-
it('should not throw to start if already started', async () => {
44+
it('starting should not throw if already started', async () => {
4545
await pubsub.start()
4646
await pubsub.start()
4747
expect(sinonMockRegistrar.register.calledOnce).to.be.true()
@@ -64,7 +64,7 @@ describe('pubsub base protocol', () => {
6464
})
6565
})
6666

67-
describe('should handle messages creating and signing', () => {
67+
describe('should handle message creation and signing', () => {
6868
let peerInfo
6969
let pubsub
7070

0 commit comments

Comments
 (0)