@libp2p/pubsub 8.0.10 → 8.0.11
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/index.min.js +9 -9
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +32 -33
- package/dist/src/index.js.map +1 -1
- package/dist/src/peer-streams.d.ts +7 -5
- package/dist/src/peer-streams.d.ts.map +1 -1
- package/dist/src/peer-streams.js +14 -9
- package/dist/src/peer-streams.js.map +1 -1
- package/dist/src/sign.d.ts +1 -2
- package/dist/src/sign.d.ts.map +1 -1
- package/dist/src/sign.js.map +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/typedoc-urls.json +2 -0
- package/package.json +20 -16
- package/src/index.ts +35 -37
- package/src/peer-streams.ts +23 -19
- package/src/sign.ts +1 -2
- package/src/utils.ts +2 -2
package/package.json
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "@libp2p/pubsub",
|
3
|
-
"version": "8.0.
|
3
|
+
"version": "8.0.11",
|
4
4
|
"description": "libp2p pubsub base class",
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
6
|
-
"homepage": "https://github.com/libp2p/js-libp2p/tree/
|
6
|
+
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/pubsub#readme",
|
7
7
|
"repository": {
|
8
8
|
"type": "git",
|
9
9
|
"url": "git+https://github.com/libp2p/js-libp2p.git"
|
@@ -11,6 +11,10 @@
|
|
11
11
|
"bugs": {
|
12
12
|
"url": "https://github.com/libp2p/js-libp2p/issues"
|
13
13
|
},
|
14
|
+
"publishConfig": {
|
15
|
+
"access": "public",
|
16
|
+
"provenance": true
|
17
|
+
},
|
14
18
|
"keywords": [
|
15
19
|
"interface",
|
16
20
|
"libp2p"
|
@@ -67,7 +71,7 @@
|
|
67
71
|
"scripts": {
|
68
72
|
"clean": "aegir clean",
|
69
73
|
"lint": "aegir lint",
|
70
|
-
"dep-check": "aegir dep-check
|
74
|
+
"dep-check": "aegir dep-check",
|
71
75
|
"build": "aegir build",
|
72
76
|
"generate": "protons test/message/rpc.proto",
|
73
77
|
"test": "aegir test",
|
@@ -79,30 +83,30 @@
|
|
79
83
|
"test:electron-main": "aegir test -t electron-main"
|
80
84
|
},
|
81
85
|
"dependencies": {
|
82
|
-
"@libp2p/crypto": "^
|
83
|
-
"@libp2p/interface": "^0.
|
84
|
-
"@libp2p/interface-internal": "^0.1.
|
85
|
-
"@libp2p/
|
86
|
-
"@libp2p/peer-
|
87
|
-
"@libp2p/
|
88
|
-
"
|
89
|
-
"it-length-prefixed": "^9.0.1",
|
86
|
+
"@libp2p/crypto": "^3.0.0",
|
87
|
+
"@libp2p/interface": "^1.0.0",
|
88
|
+
"@libp2p/interface-internal": "^0.1.10",
|
89
|
+
"@libp2p/peer-collections": "^4.0.9",
|
90
|
+
"@libp2p/peer-id": "^4.0.0",
|
91
|
+
"@libp2p/utils": "^5.0.0",
|
92
|
+
"it-length-prefixed": "^9.0.3",
|
90
93
|
"it-pipe": "^3.0.1",
|
91
|
-
"it-pushable": "^3.2.
|
92
|
-
"multiformats": "^12.
|
93
|
-
"p-queue": "^7.
|
94
|
+
"it-pushable": "^3.2.1",
|
95
|
+
"multiformats": "^12.1.3",
|
96
|
+
"p-queue": "^7.4.1",
|
94
97
|
"uint8arraylist": "^2.4.3",
|
95
98
|
"uint8arrays": "^4.0.6"
|
96
99
|
},
|
97
100
|
"devDependencies": {
|
98
|
-
"@libp2p/
|
101
|
+
"@libp2p/logger": "^4.0.0",
|
102
|
+
"@libp2p/peer-id-factory": "^3.0.9",
|
99
103
|
"@types/sinon": "^17.0.0",
|
100
104
|
"aegir": "^41.0.2",
|
101
105
|
"delay": "^6.0.0",
|
102
106
|
"it-pair": "^2.0.6",
|
103
107
|
"p-defer": "^4.0.0",
|
104
108
|
"p-wait-for": "^5.0.2",
|
105
|
-
"protons": "^7.0
|
109
|
+
"protons": "^7.3.0",
|
106
110
|
"protons-runtime": "^5.0.0",
|
107
111
|
"sinon": "^17.0.0"
|
108
112
|
}
|
package/src/index.ts
CHANGED
@@ -13,10 +13,8 @@
|
|
13
13
|
* ```
|
14
14
|
*/
|
15
15
|
|
16
|
-
import { CodeError } from '@libp2p/interface
|
17
|
-
import {
|
18
|
-
import { type PubSub, type Message, type StrictNoSign, type StrictSign, type PubSubInit, type PubSubEvents, type PeerStreams, type PubSubRPCMessage, type PubSubRPC, type PubSubRPCSubscription, type SubscriptionChangeData, type PublishResult, type TopicValidatorFn, TopicValidatorResult } from '@libp2p/interface/pubsub'
|
19
|
-
import { logger } from '@libp2p/logger'
|
16
|
+
import { CodeError, TypedEventEmitter, CustomEvent } from '@libp2p/interface'
|
17
|
+
import { type PubSub, type Message, type StrictNoSign, type StrictSign, type PubSubInit, type PubSubEvents, type PeerStreams, type PubSubRPCMessage, type PubSubRPC, type PubSubRPCSubscription, type SubscriptionChangeData, type PublishResult, type TopicValidatorFn, TopicValidatorResult, type ComponentLogger, type Logger, type Connection, type PeerId } from '@libp2p/interface'
|
20
18
|
import { PeerMap, PeerSet } from '@libp2p/peer-collections'
|
21
19
|
import { pipe } from 'it-pipe'
|
22
20
|
import Queue from 'p-queue'
|
@@ -27,16 +25,13 @@ import {
|
|
27
25
|
verifySignature
|
28
26
|
} from './sign.js'
|
29
27
|
import { toMessage, ensureArray, noSignMsgId, msgId, toRpcMessage, randomSeqno } from './utils.js'
|
30
|
-
import type {
|
31
|
-
import type { PeerId } from '@libp2p/interface/peer-id'
|
32
|
-
import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar'
|
28
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal'
|
33
29
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
34
30
|
|
35
|
-
const log = logger('libp2p:pubsub')
|
36
|
-
|
37
31
|
export interface PubSubComponents {
|
38
32
|
peerId: PeerId
|
39
33
|
registrar: Registrar
|
34
|
+
logger: ComponentLogger
|
40
35
|
}
|
41
36
|
|
42
37
|
/**
|
@@ -44,6 +39,8 @@ export interface PubSubComponents {
|
|
44
39
|
* and specifies the API that pubsub routers should have.
|
45
40
|
*/
|
46
41
|
export abstract class PubSubBaseProtocol<Events extends Record<string, any> = PubSubEvents> extends TypedEventEmitter<Events> implements PubSub<Events> {
|
42
|
+
protected log: Logger
|
43
|
+
|
47
44
|
public started: boolean
|
48
45
|
/**
|
49
46
|
* Map of topics to which peers are subscribed to
|
@@ -98,6 +95,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
98
95
|
maxOutboundStreams = 1
|
99
96
|
} = props
|
100
97
|
|
98
|
+
this.log = components.logger.forComponent('libp2p:pubsub')
|
101
99
|
this.components = components
|
102
100
|
this.multicodecs = ensureArray(multicodecs)
|
103
101
|
this.enabled = props.enabled !== false
|
@@ -128,7 +126,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
128
126
|
return
|
129
127
|
}
|
130
128
|
|
131
|
-
log('starting')
|
129
|
+
this.log('starting')
|
132
130
|
|
133
131
|
const registrar = this.components.registrar
|
134
132
|
// Incoming streams
|
@@ -148,7 +146,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
148
146
|
}
|
149
147
|
this._registrarTopologyIds = await Promise.all(this.multicodecs.map(async multicodec => registrar.register(multicodec, topology)))
|
150
148
|
|
151
|
-
log('started')
|
149
|
+
this.log('started')
|
152
150
|
this.started = true
|
153
151
|
}
|
154
152
|
|
@@ -173,7 +171,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
173
171
|
await registrar.unhandle(multicodec)
|
174
172
|
}))
|
175
173
|
|
176
|
-
log('stopping')
|
174
|
+
this.log('stopping')
|
177
175
|
for (const peerStreams of this.peers.values()) {
|
178
176
|
peerStreams.close()
|
179
177
|
}
|
@@ -181,7 +179,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
181
179
|
this.peers.clear()
|
182
180
|
this.subscriptions = new Set()
|
183
181
|
this.started = false
|
184
|
-
log('stopped')
|
182
|
+
this.log('stopped')
|
185
183
|
}
|
186
184
|
|
187
185
|
isStarted (): boolean {
|
@@ -204,18 +202,18 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
204
202
|
const inboundStream = peer.attachInboundStream(stream)
|
205
203
|
|
206
204
|
this.processMessages(peerId, inboundStream, peer)
|
207
|
-
.catch(err => { log(err) })
|
205
|
+
.catch(err => { this.log(err) })
|
208
206
|
}
|
209
207
|
|
210
208
|
/**
|
211
209
|
* Registrar notifies an established connection with pubsub protocol
|
212
210
|
*/
|
213
211
|
protected _onPeerConnected (peerId: PeerId, conn: Connection): void {
|
214
|
-
log('connected %p', peerId)
|
212
|
+
this.log('connected %p', peerId)
|
215
213
|
|
216
214
|
// if this connection is already in use for pubsub, ignore it
|
217
215
|
if (conn.streams.find(stream => stream.direction === 'outbound' && stream.protocol != null && this.multicodecs.includes(stream.protocol)) != null) {
|
218
|
-
log('outbound pubsub streams already present on connection from %p', peerId)
|
216
|
+
this.log('outbound pubsub streams already present on connection from %p', peerId)
|
219
217
|
return
|
220
218
|
}
|
221
219
|
|
@@ -231,14 +229,14 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
231
229
|
const peer = this.addPeer(peerId, stream.protocol)
|
232
230
|
await peer.attachOutboundStream(stream)
|
233
231
|
} catch (err: any) {
|
234
|
-
log.error(err)
|
232
|
+
this.log.error(err)
|
235
233
|
}
|
236
234
|
|
237
235
|
// Immediately send my own subscriptions to the newly established conn
|
238
236
|
this.send(peerId, { subscriptions: Array.from(this.subscriptions).map(sub => sub.toString()), subscribe: true })
|
239
237
|
})
|
240
238
|
.catch(err => {
|
241
|
-
log.error(err)
|
239
|
+
this.log.error(err)
|
242
240
|
})
|
243
241
|
}
|
244
242
|
|
@@ -248,7 +246,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
248
246
|
protected _onPeerDisconnected (peerId: PeerId, conn?: Connection): void {
|
249
247
|
const idB58Str = peerId.toString()
|
250
248
|
|
251
|
-
log('connection ended', idB58Str)
|
249
|
+
this.log('connection ended', idB58Str)
|
252
250
|
this._removePeer(peerId)
|
253
251
|
}
|
254
252
|
|
@@ -264,9 +262,9 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
264
262
|
}
|
265
263
|
|
266
264
|
// else create a new peer streams
|
267
|
-
log('new peer %p', peerId)
|
265
|
+
this.log('new peer %p', peerId)
|
268
266
|
|
269
|
-
const peerStreams: PeerStreams = new PeerStreamsImpl({
|
267
|
+
const peerStreams: PeerStreams = new PeerStreamsImpl(this.components, {
|
270
268
|
id: peerId,
|
271
269
|
protocol
|
272
270
|
})
|
@@ -292,7 +290,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
292
290
|
peerStreams.close()
|
293
291
|
|
294
292
|
// delete peer streams
|
295
|
-
log('delete peer %p', peerId)
|
293
|
+
this.log('delete peer %p', peerId)
|
296
294
|
this.peers.delete(peerId)
|
297
295
|
|
298
296
|
// remove peer from topics map
|
@@ -319,7 +317,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
319
317
|
|
320
318
|
for (const msg of (rpcMsg.messages ?? [])) {
|
321
319
|
if (msg.from == null || msg.data == null || msg.topic == null) {
|
322
|
-
log('message from %p was missing from, data or topic fields, dropping', peerId)
|
320
|
+
this.log('message from %p was missing from, data or topic fields, dropping', peerId)
|
323
321
|
continue
|
324
322
|
}
|
325
323
|
|
@@ -344,7 +342,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
344
342
|
})),
|
345
343
|
messages
|
346
344
|
})
|
347
|
-
.catch(err => { log(err) })
|
345
|
+
.catch(err => { this.log(err) })
|
348
346
|
}
|
349
347
|
}
|
350
348
|
)
|
@@ -358,16 +356,16 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
358
356
|
*/
|
359
357
|
async processRpc (from: PeerId, peerStreams: PeerStreams, rpc: PubSubRPC): Promise<boolean> {
|
360
358
|
if (!this.acceptFrom(from)) {
|
361
|
-
log('received message from unacceptable peer %p', from)
|
359
|
+
this.log('received message from unacceptable peer %p', from)
|
362
360
|
return false
|
363
361
|
}
|
364
362
|
|
365
|
-
log('rpc from %p', from)
|
363
|
+
this.log('rpc from %p', from)
|
366
364
|
|
367
365
|
const { subscriptions, messages } = rpc
|
368
366
|
|
369
367
|
if (subscriptions != null && subscriptions.length > 0) {
|
370
|
-
log('subscription update from %p', from)
|
368
|
+
this.log('subscription update from %p', from)
|
371
369
|
|
372
370
|
// update peer subscriptions
|
373
371
|
subscriptions.forEach((subOpt) => {
|
@@ -386,11 +384,11 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
386
384
|
}
|
387
385
|
|
388
386
|
if (messages != null && messages.length > 0) {
|
389
|
-
log('messages from %p', from)
|
387
|
+
this.log('messages from %p', from)
|
390
388
|
|
391
389
|
this.queue.addAll(messages.map(message => async () => {
|
392
390
|
if (message.topic == null || (!this.subscriptions.has(message.topic) && !this.canRelayMessage)) {
|
393
|
-
log('received message we didn\'t subscribe to. Dropping.')
|
391
|
+
this.log('received message we didn\'t subscribe to. Dropping.')
|
394
392
|
return false
|
395
393
|
}
|
396
394
|
|
@@ -399,10 +397,10 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
399
397
|
|
400
398
|
await this.processMessage(from, msg)
|
401
399
|
} catch (err: any) {
|
402
|
-
log.error(err)
|
400
|
+
this.log.error(err)
|
403
401
|
}
|
404
402
|
}))
|
405
|
-
.catch(err => { log(err) })
|
403
|
+
.catch(err => { this.log(err) })
|
406
404
|
}
|
407
405
|
|
408
406
|
return true
|
@@ -445,7 +443,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
445
443
|
try {
|
446
444
|
await this.validate(from, msg)
|
447
445
|
} catch (err: any) {
|
448
|
-
log('Message is invalid, dropping it. %O', err)
|
446
|
+
this.log('Message is invalid, dropping it. %O', err)
|
449
447
|
return
|
450
448
|
}
|
451
449
|
|
@@ -535,13 +533,13 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
535
533
|
const peerStreams = this.peers.get(peer)
|
536
534
|
|
537
535
|
if (peerStreams == null) {
|
538
|
-
log.error('Cannot send RPC to %p as there are no streams to it available', peer)
|
536
|
+
this.log.error('Cannot send RPC to %p as there are no streams to it available', peer)
|
539
537
|
|
540
538
|
return
|
541
539
|
}
|
542
540
|
|
543
541
|
if (!peerStreams.isWritable) {
|
544
|
-
log.error('Cannot send RPC to %p as there is no outbound stream to it available', peer)
|
542
|
+
this.log.error('Cannot send RPC to %p as there is no outbound stream to it available', peer)
|
545
543
|
|
546
544
|
return
|
547
545
|
}
|
@@ -664,7 +662,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
664
662
|
sequenceNumber: randomSeqno()
|
665
663
|
}
|
666
664
|
|
667
|
-
log('publish topic: %s from: %p data: %m', topic, message.from, message.data)
|
665
|
+
this.log('publish topic: %s from: %p data: %m', topic, message.from, message.data)
|
668
666
|
|
669
667
|
const rpcMessage = await this.buildMessage(message)
|
670
668
|
let emittedToSelf = false
|
@@ -706,7 +704,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
706
704
|
throw new Error('Pubsub has not started')
|
707
705
|
}
|
708
706
|
|
709
|
-
log('subscribe to topic: %s', topic)
|
707
|
+
this.log('subscribe to topic: %s', topic)
|
710
708
|
|
711
709
|
if (!this.subscriptions.has(topic)) {
|
712
710
|
this.subscriptions.add(topic)
|
@@ -729,7 +727,7 @@ export abstract class PubSubBaseProtocol<Events extends Record<string, any> = Pu
|
|
729
727
|
|
730
728
|
const wasSubscribed = this.subscriptions.has(topic)
|
731
729
|
|
732
|
-
log('unsubscribe from %s - am subscribed %s', topic, wasSubscribed)
|
730
|
+
this.log('unsubscribe from %s - am subscribed %s', topic, wasSubscribed)
|
733
731
|
|
734
732
|
if (wasSubscribed) {
|
735
733
|
this.subscriptions.delete(topic)
|
package/src/peer-streams.ts
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
import { TypedEventEmitter, CustomEvent } from '@libp2p/interface
|
2
|
-
import {
|
3
|
-
import { abortableSource } from 'abortable-iterator'
|
1
|
+
import { TypedEventEmitter, CustomEvent } from '@libp2p/interface'
|
2
|
+
import { closeSource } from '@libp2p/utils/close-source'
|
4
3
|
import * as lp from 'it-length-prefixed'
|
5
4
|
import { pipe } from 'it-pipe'
|
6
5
|
import { pushable } from 'it-pushable'
|
7
6
|
import { Uint8ArrayList } from 'uint8arraylist'
|
8
|
-
import type { Stream } from '@libp2p/interface
|
9
|
-
import type { PeerId } from '@libp2p/interface/peer-id'
|
10
|
-
import type { PeerStreamEvents } from '@libp2p/interface/pubsub'
|
7
|
+
import type { ComponentLogger, Logger, Stream, PeerId, PeerStreamEvents } from '@libp2p/interface'
|
11
8
|
import type { Pushable } from 'it-pushable'
|
12
9
|
|
13
|
-
const log = logger('libp2p-pubsub:peer-streams')
|
14
|
-
|
15
10
|
export interface PeerStreamsInit {
|
16
11
|
id: PeerId
|
17
12
|
protocol: string
|
18
13
|
}
|
19
14
|
|
15
|
+
export interface PeerStreamsComponents {
|
16
|
+
logger: ComponentLogger
|
17
|
+
}
|
18
|
+
|
20
19
|
/**
|
21
20
|
* Thin wrapper around a peer's inbound / outbound pubsub streams
|
22
21
|
*/
|
@@ -44,10 +43,12 @@ export class PeerStreams extends TypedEventEmitter<PeerStreamEvents> {
|
|
44
43
|
*/
|
45
44
|
private readonly _inboundAbortController: AbortController
|
46
45
|
private closed: boolean
|
46
|
+
private readonly log: Logger
|
47
47
|
|
48
|
-
constructor (init: PeerStreamsInit) {
|
48
|
+
constructor (components: PeerStreamsComponents, init: PeerStreamsInit) {
|
49
49
|
super()
|
50
50
|
|
51
|
+
this.log = components.logger.forComponent('libp2p-pubsub:peer-streams')
|
51
52
|
this.id = init.id
|
52
53
|
this.protocol = init.protocol
|
53
54
|
|
@@ -86,18 +87,22 @@ export class PeerStreams extends TypedEventEmitter<PeerStreamEvents> {
|
|
86
87
|
* Attach a raw inbound stream and setup a read stream
|
87
88
|
*/
|
88
89
|
attachInboundStream (stream: Stream): AsyncIterable<Uint8ArrayList> {
|
90
|
+
const abortListener = (): void => {
|
91
|
+
closeSource(stream.source, this.log)
|
92
|
+
}
|
93
|
+
|
94
|
+
this._inboundAbortController.signal.addEventListener('abort', abortListener, {
|
95
|
+
once: true
|
96
|
+
})
|
97
|
+
|
89
98
|
// Create and attach a new inbound stream
|
90
99
|
// The inbound stream is:
|
91
100
|
// - abortable, set to only return on abort, rather than throw
|
92
101
|
// - transformed with length-prefix transform
|
93
102
|
this._rawInboundStream = stream
|
94
|
-
this.inboundStream =
|
95
|
-
|
96
|
-
|
97
|
-
(source) => lp.decode(source)
|
98
|
-
),
|
99
|
-
this._inboundAbortController.signal,
|
100
|
-
{ returnOnAbort: true }
|
103
|
+
this.inboundStream = pipe(
|
104
|
+
this._rawInboundStream,
|
105
|
+
(source) => lp.decode(source)
|
101
106
|
)
|
102
107
|
|
103
108
|
this.dispatchEvent(new CustomEvent('stream:inbound'))
|
@@ -117,13 +122,12 @@ export class PeerStreams extends TypedEventEmitter<PeerStreamEvents> {
|
|
117
122
|
|
118
123
|
this._rawOutboundStream = stream
|
119
124
|
this.outboundStream = pushable<Uint8ArrayList>({
|
120
|
-
objectMode: true,
|
121
125
|
onEnd: (shouldEmit) => {
|
122
126
|
// close writable side of the stream
|
123
127
|
if (this._rawOutboundStream != null) { // eslint-disable-line @typescript-eslint/prefer-optional-chain
|
124
128
|
this._rawOutboundStream.closeWrite()
|
125
129
|
.catch(err => {
|
126
|
-
log('error closing outbound stream', err)
|
130
|
+
this.log('error closing outbound stream', err)
|
127
131
|
})
|
128
132
|
}
|
129
133
|
|
@@ -140,7 +144,7 @@ export class PeerStreams extends TypedEventEmitter<PeerStreamEvents> {
|
|
140
144
|
(source) => lp.encode(source),
|
141
145
|
this._rawOutboundStream
|
142
146
|
).catch((err: Error) => {
|
143
|
-
log.error(err)
|
147
|
+
this.log.error(err)
|
144
148
|
})
|
145
149
|
|
146
150
|
// Only emit if the connection is new
|
package/src/sign.ts
CHANGED
@@ -3,8 +3,7 @@ import { peerIdFromKeys } from '@libp2p/peer-id'
|
|
3
3
|
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
|
4
4
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
5
5
|
import { toRpcMessage } from './utils.js'
|
6
|
-
import type { PeerId } from '@libp2p/interface
|
7
|
-
import type { PubSubRPCMessage, SignedMessage } from '@libp2p/interface/pubsub'
|
6
|
+
import type { PeerId, PubSubRPCMessage, SignedMessage } from '@libp2p/interface'
|
8
7
|
|
9
8
|
export const SignPrefix = uint8ArrayFromString('libp2p-pubsub:')
|
10
9
|
|
package/src/utils.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { randomBytes } from '@libp2p/crypto'
|
2
|
-
import { CodeError } from '@libp2p/interface
|
2
|
+
import { CodeError } from '@libp2p/interface'
|
3
3
|
import { peerIdFromBytes, peerIdFromKeys } from '@libp2p/peer-id'
|
4
4
|
import { sha256 } from 'multiformats/hashes/sha2'
|
5
5
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
6
6
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
7
7
|
import { codes } from './errors.js'
|
8
|
-
import type { Message, PubSubRPCMessage } from '@libp2p/interface
|
8
|
+
import type { Message, PubSubRPCMessage } from '@libp2p/interface'
|
9
9
|
|
10
10
|
/**
|
11
11
|
* Generate a random sequence number
|