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

Commit

Permalink
feat: emit self default to false (#89)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: messages are not self emitted by default anymore. You need to set the emitSelf option to true to use it
  • Loading branch information
vasco-santos authored Sep 6, 2019
1 parent b7a1366 commit 39ff708
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const floodsub = new Floodsub(libp2pNode, options)

Options is an optional object with the following key-value pairs:

* **`emitSelf`**: boolean identifying whether the node should emit to self on publish, in the event of the topic being subscribed (defaults to **true**).
* **`emitSelf`**: boolean identifying whether the node should emit to self on publish, in the event of the topic being subscribed (defaults to **false**).

For more, see https://libp2p.github.io/js-libp2p-floodsub

Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FloodSub extends BaseProtocol {
/**
* @param {Object} libp2p an instance of Libp2p
* @param {Object} [options]
* @param {boolean} options.emitSelf if publish should emit to self, if subscribed, defaults to true
* @param {boolean} options.emitSelf if publish should emit to self, if subscribed, defaults to false
* @constructor
*/
constructor (libp2p, options = {}) {
Expand All @@ -39,7 +39,7 @@ class FloodSub extends BaseProtocol {
* Pubsub options
*/
this._options = {
emitSelf: true,
emitSelf: false,
...options
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/2-nodes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ describe('basics between 2 nodes', () => {
})

it('Mount the pubsub protocol', (done) => {
fsA = new FloodSub(nodeA)
fsB = new FloodSub(nodeB)
fsA = new FloodSub(nodeA, { emitSelf: true })
fsB = new FloodSub(nodeB, { emitSelf: true })

setTimeout(() => {
expect(fsA.peers.size).to.be.eql(0)
Expand Down Expand Up @@ -369,8 +369,8 @@ describe('basics between 2 nodes', () => {
})

it('dial on floodsub on mount', (done) => {
fsA = new FloodSub(nodeA)
fsB = new FloodSub(nodeB)
fsA = new FloodSub(nodeA, { emitSelf: true })
fsB = new FloodSub(nodeB, { emitSelf: true })

parallel([
(cb) => fsA.start(cb),
Expand Down
2 changes: 1 addition & 1 deletion test/multiple-nodes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ function spawnPubSubNode (callback) {
if (err) {
return callback(err)
}
const ps = new FloodSub(node)
const ps = new FloodSub(node, { emitSelf: true })
ps.start((err) => {
if (err) {
return callback(err)
Expand Down
2 changes: 1 addition & 1 deletion test/pubsub.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('pubsub', () => {
createNode((err, node) => {
expect(err).to.not.exist()
libp2p = node
floodsub = new Floodsub(libp2p)
floodsub = new Floodsub(libp2p, { emitSelf: true })
done(err)
})
})
Expand Down

0 comments on commit 39ff708

Please sign in to comment.