Skip to content

Commit ca99ce9

Browse files
committed
fix: use strict signing properly and fix callback issue
1 parent 8d7a9b4 commit ca99ce9

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ class PubsubBaseProtocol extends EventEmitter {
5050
this.peerId = this.libp2p.peerInfo.id
5151
}
5252

53+
/**
54+
* If message signing should be required for incoming messages
55+
* @type {boolean}
56+
*/
57+
this.strictSigning = options.strictSigning
58+
5359
/**
5460
* Map of topics to which peers are subscribed to
5561
*
@@ -374,6 +380,9 @@ class PubsubBaseProtocol extends EventEmitter {
374380
if (err) return callback(err)
375381
callback(null, valid)
376382
})
383+
} else {
384+
// The message is valid
385+
nextTick(callback, null, true)
377386
}
378387
}
379388
}

test/pubsub.spec.js

-5
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ describe('pubsub base protocol', () => {
103103
psA._buildMessage(message, (err, signedMessage) => {
104104
expect(err).to.not.exist()
105105

106-
// const bytesToSign = Buffer.concat([
107-
// SignPrefix,
108-
// Message.encode(normalizeOutRpcMessage(message))
109-
// ])
110-
111106
psA.validate(signedMessage, (err, verified) => {
112107
expect(verified).to.eql(true)
113108
done(err)

0 commit comments

Comments
 (0)