@libp2p/floodsub 10.1.46 → 11.0.0-049bfa0fa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,641 @@
1
+ import { InvalidMessageError, NotStartedError, InvalidParametersError, serviceCapabilities, serviceDependencies } from '@libp2p/interface';
2
+ import { PeerMap, PeerSet } from '@libp2p/peer-collections';
3
+ import { pipe } from 'it-pipe';
4
+ import { TypedEventEmitter } from 'main-event';
5
+ import Queue from 'p-queue';
6
+ import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
7
+ import { SimpleTimeCache } from './cache.js';
8
+ import { pubSubSymbol } from "./constants.js";
9
+ import { RPC } from './message/rpc.js';
10
+ import { PeerStreams, PeerStreams as PeerStreamsImpl } from './peer-streams.js';
11
+ import { signMessage, verifySignature } from './sign.js';
12
+ import { toMessage, ensureArray, noSignMsgId, msgId, toRpcMessage, randomSeqno } from './utils.js';
13
+ import { protocol, StrictNoSign, TopicValidatorResult, StrictSign } from './index.js';
14
+ /**
15
+ * PubSubBaseProtocol handles the peers and connections logic for pubsub routers
16
+ * and specifies the API that pubsub routers should have.
17
+ */
18
+ export class FloodSub extends TypedEventEmitter {
19
+ log;
20
+ started;
21
+ /**
22
+ * Map of topics to which peers are subscribed to
23
+ */
24
+ topics;
25
+ /**
26
+ * List of our subscriptions
27
+ */
28
+ subscriptions;
29
+ /**
30
+ * Map of peer streams
31
+ */
32
+ peers;
33
+ /**
34
+ * The signature policy to follow by default
35
+ */
36
+ globalSignaturePolicy;
37
+ /**
38
+ * If router can relay received messages, even if not subscribed
39
+ */
40
+ canRelayMessage;
41
+ /**
42
+ * if publish should emit to self, if subscribed
43
+ */
44
+ emitSelf;
45
+ /**
46
+ * Topic validator map
47
+ *
48
+ * Keyed by topic
49
+ * Topic validators are functions with the following input:
50
+ */
51
+ topicValidators;
52
+ queue;
53
+ protocols;
54
+ components;
55
+ _registrarTopologyIds;
56
+ maxInboundStreams;
57
+ maxOutboundStreams;
58
+ seenCache;
59
+ constructor(components, init) {
60
+ super();
61
+ this.log = components.logger.forComponent('libp2p:floodsub');
62
+ this.components = components;
63
+ this.protocols = ensureArray(init.protocols ?? protocol);
64
+ this.started = false;
65
+ this.topics = new Map();
66
+ this.subscriptions = new Set();
67
+ this.peers = new PeerMap();
68
+ this.globalSignaturePolicy = init.globalSignaturePolicy === 'StrictNoSign' ? 'StrictNoSign' : 'StrictSign';
69
+ this.canRelayMessage = init.canRelayMessage ?? true;
70
+ this.emitSelf = init.emitSelf ?? false;
71
+ this.topicValidators = new Map();
72
+ this.queue = new Queue({
73
+ concurrency: init.messageProcessingConcurrency ?? 10
74
+ });
75
+ this.maxInboundStreams = init.maxInboundStreams ?? 1;
76
+ this.maxOutboundStreams = init.maxOutboundStreams ?? 1;
77
+ this.seenCache = new SimpleTimeCache({
78
+ validityMs: init?.seenTTL ?? 30000
79
+ });
80
+ this._onIncomingStream = this._onIncomingStream.bind(this);
81
+ this._onPeerConnected = this._onPeerConnected.bind(this);
82
+ this._onPeerDisconnected = this._onPeerDisconnected.bind(this);
83
+ }
84
+ [pubSubSymbol] = true;
85
+ [Symbol.toStringTag] = '@libp2p/floodsub';
86
+ [serviceCapabilities] = [
87
+ '@libp2p/pubsub'
88
+ ];
89
+ [serviceDependencies] = [
90
+ '@libp2p/identify'
91
+ ];
92
+ // LIFECYCLE METHODS
93
+ /**
94
+ * Register the pubsub protocol onto the libp2p node.
95
+ */
96
+ async start() {
97
+ if (this.started) {
98
+ return;
99
+ }
100
+ this.log('starting');
101
+ const registrar = this.components.registrar;
102
+ // Incoming streams
103
+ // Called after a peer dials us
104
+ await Promise.all(this.protocols.map(async (multicodec) => {
105
+ await registrar.handle(multicodec, this._onIncomingStream, {
106
+ maxInboundStreams: this.maxInboundStreams,
107
+ maxOutboundStreams: this.maxOutboundStreams
108
+ });
109
+ }));
110
+ // register protocol with topology
111
+ // Topology callbacks called on connection manager changes
112
+ const topology = {
113
+ onConnect: this._onPeerConnected,
114
+ onDisconnect: this._onPeerDisconnected
115
+ };
116
+ this._registrarTopologyIds = await Promise.all(this.protocols.map(async (multicodec) => registrar.register(multicodec, topology)));
117
+ this.log('started');
118
+ this.started = true;
119
+ }
120
+ /**
121
+ * Unregister the pubsub protocol and the streams with other peers will be closed.
122
+ */
123
+ async stop() {
124
+ if (!this.started) {
125
+ return;
126
+ }
127
+ const registrar = this.components.registrar;
128
+ // unregister protocol and handlers
129
+ if (this._registrarTopologyIds != null) {
130
+ this._registrarTopologyIds?.forEach(id => {
131
+ registrar.unregister(id);
132
+ });
133
+ }
134
+ await Promise.all(this.protocols.map(async (multicodec) => {
135
+ await registrar.unhandle(multicodec);
136
+ }));
137
+ this.log('stopping');
138
+ for (const peerStreams of this.peers.values()) {
139
+ peerStreams.close();
140
+ }
141
+ this.peers.clear();
142
+ this.subscriptions = new Set();
143
+ this.started = false;
144
+ this.log('stopped');
145
+ }
146
+ isStarted() {
147
+ return this.started;
148
+ }
149
+ /**
150
+ * On an inbound stream opened
151
+ */
152
+ _onIncomingStream(stream, connection) {
153
+ const peerId = connection.remotePeer;
154
+ if (stream.protocol == null) {
155
+ stream.abort(new Error('Stream was not multiplexed'));
156
+ return;
157
+ }
158
+ const peer = this.addPeer(peerId, stream.protocol);
159
+ const inboundStream = peer.attachInboundStream(stream);
160
+ this.processMessages(peerId, inboundStream, peer)
161
+ .catch(err => { this.log(err); });
162
+ }
163
+ /**
164
+ * Registrar notifies an established connection with pubsub protocol
165
+ */
166
+ async _onPeerConnected(peerId, conn) {
167
+ this.log('connected %p', peerId);
168
+ // if this connection is already in use for pubsub, ignore it
169
+ if (conn.streams.find(stream => stream.direction === 'outbound' && stream.protocol != null && this.protocols.includes(stream.protocol)) != null) {
170
+ this.log('outbound pubsub streams already present on connection from %p', peerId);
171
+ return;
172
+ }
173
+ const stream = await conn.newStream(this.protocols);
174
+ if (stream.protocol == null) {
175
+ stream.abort(new Error('Stream was not multiplexed'));
176
+ return;
177
+ }
178
+ const peer = this.addPeer(peerId, stream.protocol);
179
+ await peer.attachOutboundStream(stream);
180
+ // Immediately send my own subscriptions to the newly established conn
181
+ this.send(peerId, { subscriptions: Array.from(this.subscriptions).map(sub => sub.toString()), subscribe: true });
182
+ }
183
+ /**
184
+ * Registrar notifies a closing connection with pubsub protocol
185
+ */
186
+ _onPeerDisconnected(peerId, conn) {
187
+ this.log('connection ended %p', peerId);
188
+ this._removePeer(peerId);
189
+ }
190
+ /**
191
+ * Notifies the router that a peer has been connected
192
+ */
193
+ addPeer(peerId, protocol) {
194
+ const existing = this.peers.get(peerId);
195
+ // If peer streams already exists, do nothing
196
+ if (existing != null) {
197
+ return existing;
198
+ }
199
+ // else create a new peer streams
200
+ this.log('new peer %p', peerId);
201
+ const peerStreams = new PeerStreamsImpl(this.components, {
202
+ id: peerId,
203
+ protocol
204
+ });
205
+ this.peers.set(peerId, peerStreams);
206
+ peerStreams.addEventListener('close', () => this._removePeer(peerId), {
207
+ once: true
208
+ });
209
+ return peerStreams;
210
+ }
211
+ /**
212
+ * Notifies the router that a peer has been disconnected
213
+ */
214
+ _removePeer(peerId) {
215
+ const peerStreams = this.peers.get(peerId);
216
+ if (peerStreams == null) {
217
+ return;
218
+ }
219
+ // close peer streams
220
+ peerStreams.close();
221
+ // delete peer streams
222
+ this.log('delete peer %p', peerId);
223
+ this.peers.delete(peerId);
224
+ // remove peer from topics map
225
+ for (const peers of this.topics.values()) {
226
+ peers.delete(peerId);
227
+ }
228
+ return peerStreams;
229
+ }
230
+ // MESSAGE METHODS
231
+ /**
232
+ * Responsible for processing each RPC message received by other peers.
233
+ */
234
+ async processMessages(peerId, stream, peerStreams) {
235
+ try {
236
+ await pipe(stream, async (source) => {
237
+ for await (const data of source) {
238
+ const rpcMsg = this.decodeRpc(data);
239
+ const messages = [];
240
+ for (const msg of (rpcMsg.messages ?? [])) {
241
+ if (msg.from == null || msg.data == null || msg.topic == null) {
242
+ this.log('message from %p was missing from, data or topic fields, dropping', peerId);
243
+ continue;
244
+ }
245
+ messages.push({
246
+ from: msg.from,
247
+ data: msg.data,
248
+ topic: msg.topic,
249
+ sequenceNumber: msg.sequenceNumber ?? undefined,
250
+ signature: msg.signature ?? undefined,
251
+ key: msg.key ?? undefined
252
+ });
253
+ }
254
+ // Since processRpc may be overridden entirely in unsafe ways,
255
+ // the simplest/safest option here is to wrap in a function and capture all errors
256
+ // to prevent a top-level unhandled exception
257
+ // This processing of rpc messages should happen without awaiting full validation/execution of prior messages
258
+ this.processRpc(peerId, peerStreams, {
259
+ subscriptions: (rpcMsg.subscriptions ?? []).map(sub => ({
260
+ subscribe: Boolean(sub.subscribe),
261
+ topic: sub.topic ?? ''
262
+ })),
263
+ messages
264
+ })
265
+ .catch(err => { this.log(err); });
266
+ }
267
+ });
268
+ }
269
+ catch (err) {
270
+ this._onPeerDisconnected(peerStreams.id, err);
271
+ }
272
+ }
273
+ /**
274
+ * Handles an rpc request from a peer
275
+ */
276
+ async processRpc(from, peerStreams, rpc) {
277
+ if (!this.acceptFrom(from)) {
278
+ this.log('received message from unacceptable peer %p', from);
279
+ return false;
280
+ }
281
+ this.log('rpc from %p', from);
282
+ const { subscriptions, messages } = rpc;
283
+ if (subscriptions != null && subscriptions.length > 0) {
284
+ this.log('subscription update from %p', from);
285
+ // update peer subscriptions
286
+ subscriptions.forEach((subOpt) => {
287
+ this.processRpcSubOpt(from, subOpt);
288
+ });
289
+ super.dispatchEvent(new CustomEvent('subscription-change', {
290
+ detail: {
291
+ peerId: peerStreams.id,
292
+ subscriptions: subscriptions.map(({ topic, subscribe }) => ({
293
+ topic: `${topic ?? ''}`,
294
+ subscribe: Boolean(subscribe)
295
+ }))
296
+ }
297
+ }));
298
+ }
299
+ if (messages != null && messages.length > 0) {
300
+ this.log('messages from %p', from);
301
+ this.queue.addAll(messages.map(message => async () => {
302
+ if (message.topic == null || (!this.subscriptions.has(message.topic) && !this.canRelayMessage)) {
303
+ this.log('received message we didn\'t subscribe to. Dropping.');
304
+ return false;
305
+ }
306
+ try {
307
+ const msg = await toMessage(message);
308
+ await this.processMessage(from, msg);
309
+ }
310
+ catch (err) {
311
+ this.log.error(err);
312
+ }
313
+ }))
314
+ .catch(err => { this.log(err); });
315
+ }
316
+ return true;
317
+ }
318
+ /**
319
+ * Handles a subscription change from a peer
320
+ */
321
+ processRpcSubOpt(id, subOpt) {
322
+ const t = subOpt.topic;
323
+ if (t == null) {
324
+ return;
325
+ }
326
+ let topicSet = this.topics.get(t);
327
+ if (topicSet == null) {
328
+ topicSet = new PeerSet();
329
+ this.topics.set(t, topicSet);
330
+ }
331
+ if (subOpt.subscribe === true) {
332
+ // subscribe peer to new topic
333
+ topicSet.add(id);
334
+ }
335
+ else {
336
+ // unsubscribe from existing topic
337
+ topicSet.delete(id);
338
+ }
339
+ }
340
+ /**
341
+ * Handles a message from a peer
342
+ */
343
+ async processMessage(from, msg) {
344
+ if (this.components.peerId.equals(from) && !this.emitSelf) {
345
+ return;
346
+ }
347
+ // Check if I've seen the message, if yes, ignore
348
+ const seqno = await this.getMsgId(msg);
349
+ const msgIdStr = uint8ArrayToString(seqno, 'base64');
350
+ if (this.seenCache.has(msgIdStr)) {
351
+ return;
352
+ }
353
+ this.seenCache.put(msgIdStr, true);
354
+ // Ensure the message is valid before processing it
355
+ try {
356
+ await this.validate(from, msg);
357
+ }
358
+ catch (err) {
359
+ this.log('Message is invalid, dropping it. %O', err);
360
+ return;
361
+ }
362
+ if (this.subscriptions.has(msg.topic)) {
363
+ const isFromSelf = this.components.peerId.equals(from);
364
+ if (!isFromSelf || this.emitSelf) {
365
+ super.dispatchEvent(new CustomEvent('message', {
366
+ detail: msg
367
+ }));
368
+ }
369
+ }
370
+ await this.publishMessage(from, msg);
371
+ }
372
+ /**
373
+ * The default msgID implementation
374
+ * Child class can override this.
375
+ */
376
+ getMsgId(msg) {
377
+ const signaturePolicy = this.globalSignaturePolicy;
378
+ switch (signaturePolicy) {
379
+ case 'StrictSign':
380
+ if (msg.type !== 'signed') {
381
+ throw new InvalidMessageError('Message type should be "signed" when signature policy is StrictSign but it was not');
382
+ }
383
+ if (msg.sequenceNumber == null) {
384
+ throw new InvalidMessageError('Need sequence number when signature policy is StrictSign but it was missing');
385
+ }
386
+ if (msg.key == null) {
387
+ throw new InvalidMessageError('Need key when signature policy is StrictSign but it was missing');
388
+ }
389
+ return msgId(msg.key, msg.sequenceNumber);
390
+ case 'StrictNoSign':
391
+ return noSignMsgId(msg.data);
392
+ default:
393
+ throw new InvalidMessageError('Cannot get message id: unhandled signature policy');
394
+ }
395
+ }
396
+ /**
397
+ * Whether to accept a message from a peer
398
+ * Override to create a gray list
399
+ */
400
+ acceptFrom(id) {
401
+ return true;
402
+ }
403
+ /**
404
+ * Decode Uint8Array into an RPC object.
405
+ * This can be override to use a custom router protobuf.
406
+ */
407
+ decodeRpc(bytes) {
408
+ return RPC.decode(bytes);
409
+ }
410
+ /**
411
+ * Encode RPC object into a Uint8Array.
412
+ * This can be override to use a custom router protobuf.
413
+ */
414
+ encodeRpc(rpc) {
415
+ return RPC.encode(rpc);
416
+ }
417
+ /**
418
+ * Encode RPC object into a Uint8Array.
419
+ * This can be override to use a custom router protobuf.
420
+ */
421
+ encodeMessage(rpc) {
422
+ return RPC.Message.encode(rpc);
423
+ }
424
+ /**
425
+ * Send an rpc object to a peer
426
+ */
427
+ send(peer, data) {
428
+ const { messages, subscriptions, subscribe } = data;
429
+ this.sendRpc(peer, {
430
+ subscriptions: (subscriptions ?? []).map(str => ({ topic: str, subscribe: Boolean(subscribe) })),
431
+ messages: (messages ?? []).map(toRpcMessage)
432
+ });
433
+ }
434
+ /**
435
+ * Send an rpc object to a peer
436
+ */
437
+ sendRpc(peer, rpc) {
438
+ const peerStreams = this.peers.get(peer);
439
+ if (peerStreams == null) {
440
+ this.log.error('Cannot send RPC to %p as there are no streams to it available', peer);
441
+ return;
442
+ }
443
+ if (!peerStreams.isWritable) {
444
+ this.log.error('Cannot send RPC to %p as there is no outbound stream to it available', peer);
445
+ return;
446
+ }
447
+ peerStreams.write(this.encodeRpc(rpc));
448
+ }
449
+ /**
450
+ * Validates the given message. The signature will be checked for authenticity.
451
+ * Throws an error on invalid messages
452
+ */
453
+ async validate(from, message) {
454
+ const signaturePolicy = this.globalSignaturePolicy;
455
+ switch (signaturePolicy) {
456
+ case 'StrictNoSign':
457
+ if (message.type !== 'unsigned') {
458
+ throw new InvalidMessageError('Message type should be "unsigned" when signature policy is StrictNoSign but it was not');
459
+ }
460
+ // @ts-expect-error should not be present
461
+ if (message.signature != null) {
462
+ throw new InvalidMessageError('StrictNoSigning: signature should not be present');
463
+ }
464
+ // @ts-expect-error should not be present
465
+ if (message.key != null) {
466
+ throw new InvalidMessageError('StrictNoSigning: key should not be present');
467
+ }
468
+ // @ts-expect-error should not be present
469
+ if (message.sequenceNumber != null) {
470
+ throw new InvalidMessageError('StrictNoSigning: seqno should not be present');
471
+ }
472
+ break;
473
+ case 'StrictSign':
474
+ if (message.type !== 'signed') {
475
+ throw new InvalidMessageError('Message type should be "signed" when signature policy is StrictSign but it was not');
476
+ }
477
+ if (message.signature == null) {
478
+ throw new InvalidMessageError('StrictSigning: Signing required and no signature was present');
479
+ }
480
+ if (message.sequenceNumber == null) {
481
+ throw new InvalidMessageError('StrictSigning: Signing required and no sequenceNumber was present');
482
+ }
483
+ if (!(await verifySignature(message, this.encodeMessage.bind(this)))) {
484
+ throw new InvalidMessageError('StrictSigning: Invalid message signature');
485
+ }
486
+ break;
487
+ default:
488
+ throw new InvalidMessageError('Cannot validate message: unhandled signature policy');
489
+ }
490
+ const validatorFn = this.topicValidators.get(message.topic);
491
+ if (validatorFn != null) {
492
+ const result = await validatorFn(from, message);
493
+ if (result === TopicValidatorResult.Reject || result === TopicValidatorResult.Ignore) {
494
+ throw new InvalidMessageError('Message validation failed');
495
+ }
496
+ }
497
+ }
498
+ /**
499
+ * Normalizes the message and signs it, if signing is enabled.
500
+ * Should be used by the routers to create the message to send.
501
+ */
502
+ async buildMessage(message) {
503
+ const signaturePolicy = this.globalSignaturePolicy;
504
+ switch (signaturePolicy) {
505
+ case 'StrictSign':
506
+ return signMessage(this.components.privateKey, message, this.encodeMessage.bind(this));
507
+ case 'StrictNoSign':
508
+ return Promise.resolve({
509
+ type: 'unsigned',
510
+ ...message
511
+ });
512
+ default:
513
+ throw new InvalidMessageError('Cannot build message: unhandled signature policy');
514
+ }
515
+ }
516
+ // API METHODS
517
+ /**
518
+ * Get a list of the peer-ids that are subscribed to one topic.
519
+ */
520
+ getSubscribers(topic) {
521
+ if (!this.started) {
522
+ throw new NotStartedError('not started yet');
523
+ }
524
+ if (topic == null) {
525
+ throw new InvalidParametersError('Topic is required');
526
+ }
527
+ const peersInTopic = this.topics.get(topic.toString());
528
+ if (peersInTopic == null) {
529
+ return [];
530
+ }
531
+ return Array.from(peersInTopic.values());
532
+ }
533
+ /**
534
+ * Publishes messages to all subscribed peers
535
+ */
536
+ async publish(topic, data) {
537
+ if (!this.started) {
538
+ throw new Error('Pubsub has not started');
539
+ }
540
+ const message = {
541
+ from: this.components.peerId,
542
+ topic,
543
+ data: data ?? new Uint8Array(0),
544
+ sequenceNumber: randomSeqno()
545
+ };
546
+ this.log('publish topic: %s from: %p data: %m', topic, message.from, message.data);
547
+ const rpcMessage = await this.buildMessage(message);
548
+ let emittedToSelf = false;
549
+ // dispatch the event if we are interested
550
+ if (this.emitSelf) {
551
+ if (this.subscriptions.has(topic)) {
552
+ emittedToSelf = true;
553
+ super.dispatchEvent(new CustomEvent('message', {
554
+ detail: rpcMessage
555
+ }));
556
+ }
557
+ }
558
+ // send to all the other peers
559
+ const result = await this.publishMessage(this.components.peerId, rpcMessage);
560
+ if (emittedToSelf) {
561
+ result.recipients = [...result.recipients, this.components.peerId];
562
+ }
563
+ return result;
564
+ }
565
+ /**
566
+ * Overriding the implementation of publish should handle the appropriate algorithms for the publish/subscriber implementation.
567
+ * For example, a Floodsub implementation might simply publish each message to each topic for every peer.
568
+ *
569
+ * `sender` might be this peer, or we might be forwarding a message on behalf of another peer, in which case sender
570
+ * is the peer we received the message from, which may not be the peer the message was created by.
571
+ */
572
+ async publishMessage(from, message) {
573
+ const peers = this.getSubscribers(message.topic);
574
+ const recipients = [];
575
+ if (peers == null || peers.length === 0) {
576
+ this.log('no peers are subscribed to topic %s', message.topic);
577
+ return { recipients };
578
+ }
579
+ peers.forEach(id => {
580
+ if (this.components.peerId.equals(id)) {
581
+ this.log('not sending message on topic %s to myself', message.topic);
582
+ return;
583
+ }
584
+ if (id.equals(from)) {
585
+ this.log('not sending message on topic %s to sender %p', message.topic, id);
586
+ return;
587
+ }
588
+ this.log('publish msgs on topics %s %p', message.topic, id);
589
+ recipients.push(id);
590
+ this.send(id, { messages: [message] });
591
+ });
592
+ return { recipients };
593
+ }
594
+ /**
595
+ * Subscribes to a given topic.
596
+ */
597
+ subscribe(topic) {
598
+ if (!this.started) {
599
+ throw new Error('Pubsub has not started');
600
+ }
601
+ this.log('subscribe to topic: %s', topic);
602
+ if (!this.subscriptions.has(topic)) {
603
+ this.subscriptions.add(topic);
604
+ for (const peerId of this.peers.keys()) {
605
+ this.send(peerId, { subscriptions: [topic], subscribe: true });
606
+ }
607
+ }
608
+ }
609
+ /**
610
+ * Unsubscribe from the given topic
611
+ */
612
+ unsubscribe(topic) {
613
+ if (!this.started) {
614
+ throw new Error('Pubsub is not started');
615
+ }
616
+ const wasSubscribed = this.subscriptions.has(topic);
617
+ this.log('unsubscribe from %s - am subscribed %s', topic, wasSubscribed);
618
+ if (wasSubscribed) {
619
+ this.subscriptions.delete(topic);
620
+ for (const peerId of this.peers.keys()) {
621
+ this.send(peerId, { subscriptions: [topic], subscribe: false });
622
+ }
623
+ }
624
+ }
625
+ /**
626
+ * Get the list of topics which the peer is subscribed to.
627
+ */
628
+ getTopics() {
629
+ if (!this.started) {
630
+ throw new Error('Pubsub is not started');
631
+ }
632
+ return Array.from(this.subscriptions);
633
+ }
634
+ getPeers() {
635
+ if (!this.started) {
636
+ throw new Error('Pubsub is not started');
637
+ }
638
+ return Array.from(this.peers.keys());
639
+ }
640
+ }
641
+ //# sourceMappingURL=floodsub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floodsub.js","sourceRoot":"","sources":["../../src/floodsub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC1I,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC/E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAClG,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAwBrF;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,iBAAiC;IACnD,GAAG,CAAQ;IAEd,OAAO,CAAS;IACvB;;OAEG;IACI,MAAM,CAAsB;IACnC;;OAEG;IACI,aAAa,CAAa;IACjC;;OAEG;IACI,KAAK,CAAsB;IAClC;;OAEG;IACI,qBAAqB,CAAyC;IACrE;;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