Skip to content

Commit 105f2a6

Browse files
chore: update js-libp2p-interfaces (#145)
Co-authored-by: Vasco Santos <[email protected]>
1 parent 3ead034 commit 105f2a6

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"denque": "^1.4.1",
4141
"err-code": "^2.0.0",
4242
"it-pipe": "^1.0.1",
43-
"libp2p-interfaces": "^0.6.0",
43+
"libp2p-interfaces": "^0.7.2",
4444
"peer-id": "^0.14.0",
4545
"protons": "^2.0.0",
4646
"time-cache": "^0.3.0",

ts/index.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ interface GossipInputOptions {
3131
doPX: boolean
3232
msgIdFn: MessageIdFunction
3333
messageCache: MessageCache
34-
signMessages: boolean
35-
strictSigning: boolean
34+
globalSignaturePolicy: string
3635
scoreParams: Partial<PeerScoreParams>
3736
scoreThresholds: Partial<PeerScoreThresholds>
3837
directPeers: AddrInfo[]
@@ -110,10 +109,8 @@ class Gossipsub extends Pubsub {
110109
* @param {bool} [options.fallbackToFloodsub] if dial should fallback to floodsub, defaults to true
111110
* @param {bool} [options.floodPublish] if self-published messages should be sent to all peers, defaults to true
112111
* @param {bool} [options.doPX] whether PX is enabled; this should be enabled in bootstrappers and other well connected/trusted nodes. defaults to false
113-
* @param {MessageIdFunction} [options.msgIdFn] override the default message id function
114112
* @param {Object} [options.messageCache] override the default MessageCache
115-
* @param {bool} [options.signMessages] if we want to sign outgoing messages or not (default: true)
116-
* @param {bool} [options.strictSigning] if message signing is required for incoming messages or not (default: true)
113+
* @param {string} [options.globalSignaturePolicy] signing policy to apply across all messages (default: "StrictSign")
117114
* @param {Object} [options.scoreParams] peer score parameters
118115
* @param {Object} [options.scoreThresholds] peer score thresholds
119116
* @param {AddrInfo[]} [options.directPeers] peers with which we will maintain direct connections
@@ -136,8 +133,6 @@ class Gossipsub extends Pubsub {
136133
Dscore: constants.GossipsubDscore,
137134
Dout: constants.GossipsubDout,
138135
Dlazy: constants.GossipsubDlazy,
139-
signMessages: true,
140-
strictSigning: true,
141136
...options,
142137
scoreParams: createPeerScoreParams(options.scoreParams),
143138
scoreThresholds: createPeerScoreThresholds(options.scoreThresholds)
@@ -240,17 +235,11 @@ class Gossipsub extends Pubsub {
240235
*/
241236
this.outbound = new Map()
242237

243-
/**
244-
* Use the overriden mesgIdFn or the default one.
245-
*/
246-
this.defaultMsgIdFn = (msg : InMessage) => utils.msgId(msg.from!, msg.seqno!)
247-
this._msgIdFn = options.msgIdFn || this.defaultMsgIdFn
248-
249238
/**
250239
* A message cache that contains the messages for last few hearbeat ticks
251240
*
252241
*/
253-
this.messageCache = options.messageCache || new MessageCache(constants.GossipsubHistoryGossip, constants.GossipsubHistoryLength, this._msgIdFn)
242+
this.messageCache = options.messageCache || new MessageCache(constants.GossipsubHistoryGossip, constants.GossipsubHistoryLength, this.getMsgId.bind(this))
254243

255244
/**
256245
* A heartbeat timer that maintains the mesh
@@ -266,7 +255,7 @@ class Gossipsub extends Pubsub {
266255
/**
267256
* Tracks IHAVE/IWANT promises broken by peers
268257
*/
269-
this.gossipTracer = new IWantTracer(this._msgIdFn)
258+
this.gossipTracer = new IWantTracer(this.getMsgId.bind(this))
270259

271260
/**
272261
* libp2p
@@ -276,7 +265,7 @@ class Gossipsub extends Pubsub {
276265
/**
277266
* Peer score tracking
278267
*/
279-
this.score = new PeerScore(this._options.scoreParams, libp2p.connectionManager, this._msgIdFn)
268+
this.score = new PeerScore(this._options.scoreParams, libp2p.connectionManager, this.getMsgId.bind(this))
280269
}
281270

282271
/**
@@ -1016,17 +1005,6 @@ class Gossipsub extends Pubsub {
10161005
}
10171006
}
10181007

1019-
/**
1020-
* Override the default implementation in BasicPubSub.
1021-
* If we don't provide msgIdFn in constructor option, it's the same.
1022-
* @override
1023-
* @param {InMessage} msg the message object
1024-
* @returns {Uint8Array} message id as bytes
1025-
*/
1026-
getMsgId (msg: InMessage): Uint8Array {
1027-
return this._msgIdFn(msg)
1028-
}
1029-
10301008
/**
10311009
* Publish messages
10321010
*

0 commit comments

Comments
 (0)