@libp2p/floodsub 1.0.2 → 1.0.3

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.
@@ -1,1876 +0,0 @@
1
- /*eslint-disable*/
2
- import $protobuf from "protobufjs/minimal.js";
3
-
4
- // Common aliases
5
- const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
6
-
7
- // Exported root namespace
8
- const $root = $protobuf.roots["libp2p-floodsub"] || ($protobuf.roots["libp2p-floodsub"] = {});
9
-
10
- export const RPC = $root.RPC = (() => {
11
-
12
- /**
13
- * Properties of a RPC.
14
- * @exports IRPC
15
- * @interface IRPC
16
- * @property {Array.<RPC.ISubOpts>|null} [subscriptions] RPC subscriptions
17
- * @property {Array.<RPC.IMessage>|null} [messages] RPC messages
18
- * @property {IControlMessage|null} [control] RPC control
19
- */
20
-
21
- /**
22
- * Constructs a new RPC.
23
- * @exports RPC
24
- * @classdesc Represents a RPC.
25
- * @implements IRPC
26
- * @constructor
27
- * @param {IRPC=} [p] Properties to set
28
- */
29
- function RPC(p) {
30
- this.subscriptions = [];
31
- this.messages = [];
32
- if (p)
33
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
34
- if (p[ks[i]] != null)
35
- this[ks[i]] = p[ks[i]];
36
- }
37
-
38
- /**
39
- * RPC subscriptions.
40
- * @member {Array.<RPC.ISubOpts>} subscriptions
41
- * @memberof RPC
42
- * @instance
43
- */
44
- RPC.prototype.subscriptions = $util.emptyArray;
45
-
46
- /**
47
- * RPC messages.
48
- * @member {Array.<RPC.IMessage>} messages
49
- * @memberof RPC
50
- * @instance
51
- */
52
- RPC.prototype.messages = $util.emptyArray;
53
-
54
- /**
55
- * RPC control.
56
- * @member {IControlMessage|null|undefined} control
57
- * @memberof RPC
58
- * @instance
59
- */
60
- RPC.prototype.control = null;
61
-
62
- // OneOf field names bound to virtual getters and setters
63
- let $oneOfFields;
64
-
65
- /**
66
- * RPC _control.
67
- * @member {"control"|undefined} _control
68
- * @memberof RPC
69
- * @instance
70
- */
71
- Object.defineProperty(RPC.prototype, "_control", {
72
- get: $util.oneOfGetter($oneOfFields = ["control"]),
73
- set: $util.oneOfSetter($oneOfFields)
74
- });
75
-
76
- /**
77
- * Encodes the specified RPC message. Does not implicitly {@link RPC.verify|verify} messages.
78
- * @function encode
79
- * @memberof RPC
80
- * @static
81
- * @param {IRPC} m RPC message or plain object to encode
82
- * @param {$protobuf.Writer} [w] Writer to encode to
83
- * @returns {$protobuf.Writer} Writer
84
- */
85
- RPC.encode = function encode(m, w) {
86
- if (!w)
87
- w = $Writer.create();
88
- if (m.subscriptions != null && m.subscriptions.length) {
89
- for (var i = 0; i < m.subscriptions.length; ++i)
90
- $root.RPC.SubOpts.encode(m.subscriptions[i], w.uint32(10).fork()).ldelim();
91
- }
92
- if (m.messages != null && m.messages.length) {
93
- for (var i = 0; i < m.messages.length; ++i)
94
- $root.RPC.Message.encode(m.messages[i], w.uint32(18).fork()).ldelim();
95
- }
96
- if (m.control != null && Object.hasOwnProperty.call(m, "control"))
97
- $root.ControlMessage.encode(m.control, w.uint32(26).fork()).ldelim();
98
- return w;
99
- };
100
-
101
- /**
102
- * Decodes a RPC message from the specified reader or buffer.
103
- * @function decode
104
- * @memberof RPC
105
- * @static
106
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
107
- * @param {number} [l] Message length if known beforehand
108
- * @returns {RPC} RPC
109
- * @throws {Error} If the payload is not a reader or valid buffer
110
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
111
- */
112
- RPC.decode = function decode(r, l) {
113
- if (!(r instanceof $Reader))
114
- r = $Reader.create(r);
115
- var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC();
116
- while (r.pos < c) {
117
- var t = r.uint32();
118
- switch (t >>> 3) {
119
- case 1:
120
- if (!(m.subscriptions && m.subscriptions.length))
121
- m.subscriptions = [];
122
- m.subscriptions.push($root.RPC.SubOpts.decode(r, r.uint32()));
123
- break;
124
- case 2:
125
- if (!(m.messages && m.messages.length))
126
- m.messages = [];
127
- m.messages.push($root.RPC.Message.decode(r, r.uint32()));
128
- break;
129
- case 3:
130
- m.control = $root.ControlMessage.decode(r, r.uint32());
131
- break;
132
- default:
133
- r.skipType(t & 7);
134
- break;
135
- }
136
- }
137
- return m;
138
- };
139
-
140
- /**
141
- * Creates a RPC message from a plain object. Also converts values to their respective internal types.
142
- * @function fromObject
143
- * @memberof RPC
144
- * @static
145
- * @param {Object.<string,*>} d Plain object
146
- * @returns {RPC} RPC
147
- */
148
- RPC.fromObject = function fromObject(d) {
149
- if (d instanceof $root.RPC)
150
- return d;
151
- var m = new $root.RPC();
152
- if (d.subscriptions) {
153
- if (!Array.isArray(d.subscriptions))
154
- throw TypeError(".RPC.subscriptions: array expected");
155
- m.subscriptions = [];
156
- for (var i = 0; i < d.subscriptions.length; ++i) {
157
- if (typeof d.subscriptions[i] !== "object")
158
- throw TypeError(".RPC.subscriptions: object expected");
159
- m.subscriptions[i] = $root.RPC.SubOpts.fromObject(d.subscriptions[i]);
160
- }
161
- }
162
- if (d.messages) {
163
- if (!Array.isArray(d.messages))
164
- throw TypeError(".RPC.messages: array expected");
165
- m.messages = [];
166
- for (var i = 0; i < d.messages.length; ++i) {
167
- if (typeof d.messages[i] !== "object")
168
- throw TypeError(".RPC.messages: object expected");
169
- m.messages[i] = $root.RPC.Message.fromObject(d.messages[i]);
170
- }
171
- }
172
- if (d.control != null) {
173
- if (typeof d.control !== "object")
174
- throw TypeError(".RPC.control: object expected");
175
- m.control = $root.ControlMessage.fromObject(d.control);
176
- }
177
- return m;
178
- };
179
-
180
- /**
181
- * Creates a plain object from a RPC message. Also converts values to other types if specified.
182
- * @function toObject
183
- * @memberof RPC
184
- * @static
185
- * @param {RPC} m RPC
186
- * @param {$protobuf.IConversionOptions} [o] Conversion options
187
- * @returns {Object.<string,*>} Plain object
188
- */
189
- RPC.toObject = function toObject(m, o) {
190
- if (!o)
191
- o = {};
192
- var d = {};
193
- if (o.arrays || o.defaults) {
194
- d.subscriptions = [];
195
- d.messages = [];
196
- }
197
- if (m.subscriptions && m.subscriptions.length) {
198
- d.subscriptions = [];
199
- for (var j = 0; j < m.subscriptions.length; ++j) {
200
- d.subscriptions[j] = $root.RPC.SubOpts.toObject(m.subscriptions[j], o);
201
- }
202
- }
203
- if (m.messages && m.messages.length) {
204
- d.messages = [];
205
- for (var j = 0; j < m.messages.length; ++j) {
206
- d.messages[j] = $root.RPC.Message.toObject(m.messages[j], o);
207
- }
208
- }
209
- if (m.control != null && m.hasOwnProperty("control")) {
210
- d.control = $root.ControlMessage.toObject(m.control, o);
211
- if (o.oneofs)
212
- d._control = "control";
213
- }
214
- return d;
215
- };
216
-
217
- /**
218
- * Converts this RPC to JSON.
219
- * @function toJSON
220
- * @memberof RPC
221
- * @instance
222
- * @returns {Object.<string,*>} JSON object
223
- */
224
- RPC.prototype.toJSON = function toJSON() {
225
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
226
- };
227
-
228
- RPC.SubOpts = (function() {
229
-
230
- /**
231
- * Properties of a SubOpts.
232
- * @memberof RPC
233
- * @interface ISubOpts
234
- * @property {boolean|null} [subscribe] SubOpts subscribe
235
- * @property {string|null} [topic] SubOpts topic
236
- */
237
-
238
- /**
239
- * Constructs a new SubOpts.
240
- * @memberof RPC
241
- * @classdesc Represents a SubOpts.
242
- * @implements ISubOpts
243
- * @constructor
244
- * @param {RPC.ISubOpts=} [p] Properties to set
245
- */
246
- function SubOpts(p) {
247
- if (p)
248
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
249
- if (p[ks[i]] != null)
250
- this[ks[i]] = p[ks[i]];
251
- }
252
-
253
- /**
254
- * SubOpts subscribe.
255
- * @member {boolean|null|undefined} subscribe
256
- * @memberof RPC.SubOpts
257
- * @instance
258
- */
259
- SubOpts.prototype.subscribe = null;
260
-
261
- /**
262
- * SubOpts topic.
263
- * @member {string|null|undefined} topic
264
- * @memberof RPC.SubOpts
265
- * @instance
266
- */
267
- SubOpts.prototype.topic = null;
268
-
269
- // OneOf field names bound to virtual getters and setters
270
- let $oneOfFields;
271
-
272
- /**
273
- * SubOpts _subscribe.
274
- * @member {"subscribe"|undefined} _subscribe
275
- * @memberof RPC.SubOpts
276
- * @instance
277
- */
278
- Object.defineProperty(SubOpts.prototype, "_subscribe", {
279
- get: $util.oneOfGetter($oneOfFields = ["subscribe"]),
280
- set: $util.oneOfSetter($oneOfFields)
281
- });
282
-
283
- /**
284
- * SubOpts _topic.
285
- * @member {"topic"|undefined} _topic
286
- * @memberof RPC.SubOpts
287
- * @instance
288
- */
289
- Object.defineProperty(SubOpts.prototype, "_topic", {
290
- get: $util.oneOfGetter($oneOfFields = ["topic"]),
291
- set: $util.oneOfSetter($oneOfFields)
292
- });
293
-
294
- /**
295
- * Encodes the specified SubOpts message. Does not implicitly {@link RPC.SubOpts.verify|verify} messages.
296
- * @function encode
297
- * @memberof RPC.SubOpts
298
- * @static
299
- * @param {RPC.ISubOpts} m SubOpts message or plain object to encode
300
- * @param {$protobuf.Writer} [w] Writer to encode to
301
- * @returns {$protobuf.Writer} Writer
302
- */
303
- SubOpts.encode = function encode(m, w) {
304
- if (!w)
305
- w = $Writer.create();
306
- if (m.subscribe != null && Object.hasOwnProperty.call(m, "subscribe"))
307
- w.uint32(8).bool(m.subscribe);
308
- if (m.topic != null && Object.hasOwnProperty.call(m, "topic"))
309
- w.uint32(18).string(m.topic);
310
- return w;
311
- };
312
-
313
- /**
314
- * Decodes a SubOpts message from the specified reader or buffer.
315
- * @function decode
316
- * @memberof RPC.SubOpts
317
- * @static
318
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
319
- * @param {number} [l] Message length if known beforehand
320
- * @returns {RPC.SubOpts} SubOpts
321
- * @throws {Error} If the payload is not a reader or valid buffer
322
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
323
- */
324
- SubOpts.decode = function decode(r, l) {
325
- if (!(r instanceof $Reader))
326
- r = $Reader.create(r);
327
- var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.SubOpts();
328
- while (r.pos < c) {
329
- var t = r.uint32();
330
- switch (t >>> 3) {
331
- case 1:
332
- m.subscribe = r.bool();
333
- break;
334
- case 2:
335
- m.topic = r.string();
336
- break;
337
- default:
338
- r.skipType(t & 7);
339
- break;
340
- }
341
- }
342
- return m;
343
- };
344
-
345
- /**
346
- * Creates a SubOpts message from a plain object. Also converts values to their respective internal types.
347
- * @function fromObject
348
- * @memberof RPC.SubOpts
349
- * @static
350
- * @param {Object.<string,*>} d Plain object
351
- * @returns {RPC.SubOpts} SubOpts
352
- */
353
- SubOpts.fromObject = function fromObject(d) {
354
- if (d instanceof $root.RPC.SubOpts)
355
- return d;
356
- var m = new $root.RPC.SubOpts();
357
- if (d.subscribe != null) {
358
- m.subscribe = Boolean(d.subscribe);
359
- }
360
- if (d.topic != null) {
361
- m.topic = String(d.topic);
362
- }
363
- return m;
364
- };
365
-
366
- /**
367
- * Creates a plain object from a SubOpts message. Also converts values to other types if specified.
368
- * @function toObject
369
- * @memberof RPC.SubOpts
370
- * @static
371
- * @param {RPC.SubOpts} m SubOpts
372
- * @param {$protobuf.IConversionOptions} [o] Conversion options
373
- * @returns {Object.<string,*>} Plain object
374
- */
375
- SubOpts.toObject = function toObject(m, o) {
376
- if (!o)
377
- o = {};
378
- var d = {};
379
- if (m.subscribe != null && m.hasOwnProperty("subscribe")) {
380
- d.subscribe = m.subscribe;
381
- if (o.oneofs)
382
- d._subscribe = "subscribe";
383
- }
384
- if (m.topic != null && m.hasOwnProperty("topic")) {
385
- d.topic = m.topic;
386
- if (o.oneofs)
387
- d._topic = "topic";
388
- }
389
- return d;
390
- };
391
-
392
- /**
393
- * Converts this SubOpts to JSON.
394
- * @function toJSON
395
- * @memberof RPC.SubOpts
396
- * @instance
397
- * @returns {Object.<string,*>} JSON object
398
- */
399
- SubOpts.prototype.toJSON = function toJSON() {
400
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
401
- };
402
-
403
- return SubOpts;
404
- })();
405
-
406
- RPC.Message = (function() {
407
-
408
- /**
409
- * Properties of a Message.
410
- * @memberof RPC
411
- * @interface IMessage
412
- * @property {Uint8Array|null} [from] Message from
413
- * @property {Uint8Array|null} [data] Message data
414
- * @property {Uint8Array|null} [sequenceNumber] Message sequenceNumber
415
- * @property {string|null} [topic] Message topic
416
- * @property {Uint8Array|null} [signature] Message signature
417
- * @property {Uint8Array|null} [key] Message key
418
- */
419
-
420
- /**
421
- * Constructs a new Message.
422
- * @memberof RPC
423
- * @classdesc Represents a Message.
424
- * @implements IMessage
425
- * @constructor
426
- * @param {RPC.IMessage=} [p] Properties to set
427
- */
428
- function Message(p) {
429
- if (p)
430
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
431
- if (p[ks[i]] != null)
432
- this[ks[i]] = p[ks[i]];
433
- }
434
-
435
- /**
436
- * Message from.
437
- * @member {Uint8Array|null|undefined} from
438
- * @memberof RPC.Message
439
- * @instance
440
- */
441
- Message.prototype.from = null;
442
-
443
- /**
444
- * Message data.
445
- * @member {Uint8Array|null|undefined} data
446
- * @memberof RPC.Message
447
- * @instance
448
- */
449
- Message.prototype.data = null;
450
-
451
- /**
452
- * Message sequenceNumber.
453
- * @member {Uint8Array|null|undefined} sequenceNumber
454
- * @memberof RPC.Message
455
- * @instance
456
- */
457
- Message.prototype.sequenceNumber = null;
458
-
459
- /**
460
- * Message topic.
461
- * @member {string|null|undefined} topic
462
- * @memberof RPC.Message
463
- * @instance
464
- */
465
- Message.prototype.topic = null;
466
-
467
- /**
468
- * Message signature.
469
- * @member {Uint8Array|null|undefined} signature
470
- * @memberof RPC.Message
471
- * @instance
472
- */
473
- Message.prototype.signature = null;
474
-
475
- /**
476
- * Message key.
477
- * @member {Uint8Array|null|undefined} key
478
- * @memberof RPC.Message
479
- * @instance
480
- */
481
- Message.prototype.key = null;
482
-
483
- // OneOf field names bound to virtual getters and setters
484
- let $oneOfFields;
485
-
486
- /**
487
- * Message _from.
488
- * @member {"from"|undefined} _from
489
- * @memberof RPC.Message
490
- * @instance
491
- */
492
- Object.defineProperty(Message.prototype, "_from", {
493
- get: $util.oneOfGetter($oneOfFields = ["from"]),
494
- set: $util.oneOfSetter($oneOfFields)
495
- });
496
-
497
- /**
498
- * Message _data.
499
- * @member {"data"|undefined} _data
500
- * @memberof RPC.Message
501
- * @instance
502
- */
503
- Object.defineProperty(Message.prototype, "_data", {
504
- get: $util.oneOfGetter($oneOfFields = ["data"]),
505
- set: $util.oneOfSetter($oneOfFields)
506
- });
507
-
508
- /**
509
- * Message _sequenceNumber.
510
- * @member {"sequenceNumber"|undefined} _sequenceNumber
511
- * @memberof RPC.Message
512
- * @instance
513
- */
514
- Object.defineProperty(Message.prototype, "_sequenceNumber", {
515
- get: $util.oneOfGetter($oneOfFields = ["sequenceNumber"]),
516
- set: $util.oneOfSetter($oneOfFields)
517
- });
518
-
519
- /**
520
- * Message _topic.
521
- * @member {"topic"|undefined} _topic
522
- * @memberof RPC.Message
523
- * @instance
524
- */
525
- Object.defineProperty(Message.prototype, "_topic", {
526
- get: $util.oneOfGetter($oneOfFields = ["topic"]),
527
- set: $util.oneOfSetter($oneOfFields)
528
- });
529
-
530
- /**
531
- * Message _signature.
532
- * @member {"signature"|undefined} _signature
533
- * @memberof RPC.Message
534
- * @instance
535
- */
536
- Object.defineProperty(Message.prototype, "_signature", {
537
- get: $util.oneOfGetter($oneOfFields = ["signature"]),
538
- set: $util.oneOfSetter($oneOfFields)
539
- });
540
-
541
- /**
542
- * Message _key.
543
- * @member {"key"|undefined} _key
544
- * @memberof RPC.Message
545
- * @instance
546
- */
547
- Object.defineProperty(Message.prototype, "_key", {
548
- get: $util.oneOfGetter($oneOfFields = ["key"]),
549
- set: $util.oneOfSetter($oneOfFields)
550
- });
551
-
552
- /**
553
- * Encodes the specified Message message. Does not implicitly {@link RPC.Message.verify|verify} messages.
554
- * @function encode
555
- * @memberof RPC.Message
556
- * @static
557
- * @param {RPC.IMessage} m Message message or plain object to encode
558
- * @param {$protobuf.Writer} [w] Writer to encode to
559
- * @returns {$protobuf.Writer} Writer
560
- */
561
- Message.encode = function encode(m, w) {
562
- if (!w)
563
- w = $Writer.create();
564
- if (m.from != null && Object.hasOwnProperty.call(m, "from"))
565
- w.uint32(10).bytes(m.from);
566
- if (m.data != null && Object.hasOwnProperty.call(m, "data"))
567
- w.uint32(18).bytes(m.data);
568
- if (m.sequenceNumber != null && Object.hasOwnProperty.call(m, "sequenceNumber"))
569
- w.uint32(26).bytes(m.sequenceNumber);
570
- if (m.topic != null && Object.hasOwnProperty.call(m, "topic"))
571
- w.uint32(34).string(m.topic);
572
- if (m.signature != null && Object.hasOwnProperty.call(m, "signature"))
573
- w.uint32(42).bytes(m.signature);
574
- if (m.key != null && Object.hasOwnProperty.call(m, "key"))
575
- w.uint32(50).bytes(m.key);
576
- return w;
577
- };
578
-
579
- /**
580
- * Decodes a Message message from the specified reader or buffer.
581
- * @function decode
582
- * @memberof RPC.Message
583
- * @static
584
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
585
- * @param {number} [l] Message length if known beforehand
586
- * @returns {RPC.Message} Message
587
- * @throws {Error} If the payload is not a reader or valid buffer
588
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
589
- */
590
- Message.decode = function decode(r, l) {
591
- if (!(r instanceof $Reader))
592
- r = $Reader.create(r);
593
- var c = l === undefined ? r.len : r.pos + l, m = new $root.RPC.Message();
594
- while (r.pos < c) {
595
- var t = r.uint32();
596
- switch (t >>> 3) {
597
- case 1:
598
- m.from = r.bytes();
599
- break;
600
- case 2:
601
- m.data = r.bytes();
602
- break;
603
- case 3:
604
- m.sequenceNumber = r.bytes();
605
- break;
606
- case 4:
607
- m.topic = r.string();
608
- break;
609
- case 5:
610
- m.signature = r.bytes();
611
- break;
612
- case 6:
613
- m.key = r.bytes();
614
- break;
615
- default:
616
- r.skipType(t & 7);
617
- break;
618
- }
619
- }
620
- return m;
621
- };
622
-
623
- /**
624
- * Creates a Message message from a plain object. Also converts values to their respective internal types.
625
- * @function fromObject
626
- * @memberof RPC.Message
627
- * @static
628
- * @param {Object.<string,*>} d Plain object
629
- * @returns {RPC.Message} Message
630
- */
631
- Message.fromObject = function fromObject(d) {
632
- if (d instanceof $root.RPC.Message)
633
- return d;
634
- var m = new $root.RPC.Message();
635
- if (d.from != null) {
636
- if (typeof d.from === "string")
637
- $util.base64.decode(d.from, m.from = $util.newBuffer($util.base64.length(d.from)), 0);
638
- else if (d.from.length)
639
- m.from = d.from;
640
- }
641
- if (d.data != null) {
642
- if (typeof d.data === "string")
643
- $util.base64.decode(d.data, m.data = $util.newBuffer($util.base64.length(d.data)), 0);
644
- else if (d.data.length)
645
- m.data = d.data;
646
- }
647
- if (d.sequenceNumber != null) {
648
- if (typeof d.sequenceNumber === "string")
649
- $util.base64.decode(d.sequenceNumber, m.sequenceNumber = $util.newBuffer($util.base64.length(d.sequenceNumber)), 0);
650
- else if (d.sequenceNumber.length)
651
- m.sequenceNumber = d.sequenceNumber;
652
- }
653
- if (d.topic != null) {
654
- m.topic = String(d.topic);
655
- }
656
- if (d.signature != null) {
657
- if (typeof d.signature === "string")
658
- $util.base64.decode(d.signature, m.signature = $util.newBuffer($util.base64.length(d.signature)), 0);
659
- else if (d.signature.length)
660
- m.signature = d.signature;
661
- }
662
- if (d.key != null) {
663
- if (typeof d.key === "string")
664
- $util.base64.decode(d.key, m.key = $util.newBuffer($util.base64.length(d.key)), 0);
665
- else if (d.key.length)
666
- m.key = d.key;
667
- }
668
- return m;
669
- };
670
-
671
- /**
672
- * Creates a plain object from a Message message. Also converts values to other types if specified.
673
- * @function toObject
674
- * @memberof RPC.Message
675
- * @static
676
- * @param {RPC.Message} m Message
677
- * @param {$protobuf.IConversionOptions} [o] Conversion options
678
- * @returns {Object.<string,*>} Plain object
679
- */
680
- Message.toObject = function toObject(m, o) {
681
- if (!o)
682
- o = {};
683
- var d = {};
684
- if (m.from != null && m.hasOwnProperty("from")) {
685
- d.from = o.bytes === String ? $util.base64.encode(m.from, 0, m.from.length) : o.bytes === Array ? Array.prototype.slice.call(m.from) : m.from;
686
- if (o.oneofs)
687
- d._from = "from";
688
- }
689
- if (m.data != null && m.hasOwnProperty("data")) {
690
- d.data = o.bytes === String ? $util.base64.encode(m.data, 0, m.data.length) : o.bytes === Array ? Array.prototype.slice.call(m.data) : m.data;
691
- if (o.oneofs)
692
- d._data = "data";
693
- }
694
- if (m.sequenceNumber != null && m.hasOwnProperty("sequenceNumber")) {
695
- d.sequenceNumber = o.bytes === String ? $util.base64.encode(m.sequenceNumber, 0, m.sequenceNumber.length) : o.bytes === Array ? Array.prototype.slice.call(m.sequenceNumber) : m.sequenceNumber;
696
- if (o.oneofs)
697
- d._sequenceNumber = "sequenceNumber";
698
- }
699
- if (m.topic != null && m.hasOwnProperty("topic")) {
700
- d.topic = m.topic;
701
- if (o.oneofs)
702
- d._topic = "topic";
703
- }
704
- if (m.signature != null && m.hasOwnProperty("signature")) {
705
- d.signature = o.bytes === String ? $util.base64.encode(m.signature, 0, m.signature.length) : o.bytes === Array ? Array.prototype.slice.call(m.signature) : m.signature;
706
- if (o.oneofs)
707
- d._signature = "signature";
708
- }
709
- if (m.key != null && m.hasOwnProperty("key")) {
710
- d.key = o.bytes === String ? $util.base64.encode(m.key, 0, m.key.length) : o.bytes === Array ? Array.prototype.slice.call(m.key) : m.key;
711
- if (o.oneofs)
712
- d._key = "key";
713
- }
714
- return d;
715
- };
716
-
717
- /**
718
- * Converts this Message to JSON.
719
- * @function toJSON
720
- * @memberof RPC.Message
721
- * @instance
722
- * @returns {Object.<string,*>} JSON object
723
- */
724
- Message.prototype.toJSON = function toJSON() {
725
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
726
- };
727
-
728
- return Message;
729
- })();
730
-
731
- return RPC;
732
- })();
733
-
734
- export const ControlMessage = $root.ControlMessage = (() => {
735
-
736
- /**
737
- * Properties of a ControlMessage.
738
- * @exports IControlMessage
739
- * @interface IControlMessage
740
- * @property {Array.<IControlIHave>|null} [ihave] ControlMessage ihave
741
- * @property {Array.<IControlIWant>|null} [iwant] ControlMessage iwant
742
- * @property {Array.<IControlGraft>|null} [graft] ControlMessage graft
743
- * @property {Array.<IControlPrune>|null} [prune] ControlMessage prune
744
- */
745
-
746
- /**
747
- * Constructs a new ControlMessage.
748
- * @exports ControlMessage
749
- * @classdesc Represents a ControlMessage.
750
- * @implements IControlMessage
751
- * @constructor
752
- * @param {IControlMessage=} [p] Properties to set
753
- */
754
- function ControlMessage(p) {
755
- this.ihave = [];
756
- this.iwant = [];
757
- this.graft = [];
758
- this.prune = [];
759
- if (p)
760
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
761
- if (p[ks[i]] != null)
762
- this[ks[i]] = p[ks[i]];
763
- }
764
-
765
- /**
766
- * ControlMessage ihave.
767
- * @member {Array.<IControlIHave>} ihave
768
- * @memberof ControlMessage
769
- * @instance
770
- */
771
- ControlMessage.prototype.ihave = $util.emptyArray;
772
-
773
- /**
774
- * ControlMessage iwant.
775
- * @member {Array.<IControlIWant>} iwant
776
- * @memberof ControlMessage
777
- * @instance
778
- */
779
- ControlMessage.prototype.iwant = $util.emptyArray;
780
-
781
- /**
782
- * ControlMessage graft.
783
- * @member {Array.<IControlGraft>} graft
784
- * @memberof ControlMessage
785
- * @instance
786
- */
787
- ControlMessage.prototype.graft = $util.emptyArray;
788
-
789
- /**
790
- * ControlMessage prune.
791
- * @member {Array.<IControlPrune>} prune
792
- * @memberof ControlMessage
793
- * @instance
794
- */
795
- ControlMessage.prototype.prune = $util.emptyArray;
796
-
797
- /**
798
- * Encodes the specified ControlMessage message. Does not implicitly {@link ControlMessage.verify|verify} messages.
799
- * @function encode
800
- * @memberof ControlMessage
801
- * @static
802
- * @param {IControlMessage} m ControlMessage message or plain object to encode
803
- * @param {$protobuf.Writer} [w] Writer to encode to
804
- * @returns {$protobuf.Writer} Writer
805
- */
806
- ControlMessage.encode = function encode(m, w) {
807
- if (!w)
808
- w = $Writer.create();
809
- if (m.ihave != null && m.ihave.length) {
810
- for (var i = 0; i < m.ihave.length; ++i)
811
- $root.ControlIHave.encode(m.ihave[i], w.uint32(10).fork()).ldelim();
812
- }
813
- if (m.iwant != null && m.iwant.length) {
814
- for (var i = 0; i < m.iwant.length; ++i)
815
- $root.ControlIWant.encode(m.iwant[i], w.uint32(18).fork()).ldelim();
816
- }
817
- if (m.graft != null && m.graft.length) {
818
- for (var i = 0; i < m.graft.length; ++i)
819
- $root.ControlGraft.encode(m.graft[i], w.uint32(26).fork()).ldelim();
820
- }
821
- if (m.prune != null && m.prune.length) {
822
- for (var i = 0; i < m.prune.length; ++i)
823
- $root.ControlPrune.encode(m.prune[i], w.uint32(34).fork()).ldelim();
824
- }
825
- return w;
826
- };
827
-
828
- /**
829
- * Decodes a ControlMessage message from the specified reader or buffer.
830
- * @function decode
831
- * @memberof ControlMessage
832
- * @static
833
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
834
- * @param {number} [l] Message length if known beforehand
835
- * @returns {ControlMessage} ControlMessage
836
- * @throws {Error} If the payload is not a reader or valid buffer
837
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
838
- */
839
- ControlMessage.decode = function decode(r, l) {
840
- if (!(r instanceof $Reader))
841
- r = $Reader.create(r);
842
- var c = l === undefined ? r.len : r.pos + l, m = new $root.ControlMessage();
843
- while (r.pos < c) {
844
- var t = r.uint32();
845
- switch (t >>> 3) {
846
- case 1:
847
- if (!(m.ihave && m.ihave.length))
848
- m.ihave = [];
849
- m.ihave.push($root.ControlIHave.decode(r, r.uint32()));
850
- break;
851
- case 2:
852
- if (!(m.iwant && m.iwant.length))
853
- m.iwant = [];
854
- m.iwant.push($root.ControlIWant.decode(r, r.uint32()));
855
- break;
856
- case 3:
857
- if (!(m.graft && m.graft.length))
858
- m.graft = [];
859
- m.graft.push($root.ControlGraft.decode(r, r.uint32()));
860
- break;
861
- case 4:
862
- if (!(m.prune && m.prune.length))
863
- m.prune = [];
864
- m.prune.push($root.ControlPrune.decode(r, r.uint32()));
865
- break;
866
- default:
867
- r.skipType(t & 7);
868
- break;
869
- }
870
- }
871
- return m;
872
- };
873
-
874
- /**
875
- * Creates a ControlMessage message from a plain object. Also converts values to their respective internal types.
876
- * @function fromObject
877
- * @memberof ControlMessage
878
- * @static
879
- * @param {Object.<string,*>} d Plain object
880
- * @returns {ControlMessage} ControlMessage
881
- */
882
- ControlMessage.fromObject = function fromObject(d) {
883
- if (d instanceof $root.ControlMessage)
884
- return d;
885
- var m = new $root.ControlMessage();
886
- if (d.ihave) {
887
- if (!Array.isArray(d.ihave))
888
- throw TypeError(".ControlMessage.ihave: array expected");
889
- m.ihave = [];
890
- for (var i = 0; i < d.ihave.length; ++i) {
891
- if (typeof d.ihave[i] !== "object")
892
- throw TypeError(".ControlMessage.ihave: object expected");
893
- m.ihave[i] = $root.ControlIHave.fromObject(d.ihave[i]);
894
- }
895
- }
896
- if (d.iwant) {
897
- if (!Array.isArray(d.iwant))
898
- throw TypeError(".ControlMessage.iwant: array expected");
899
- m.iwant = [];
900
- for (var i = 0; i < d.iwant.length; ++i) {
901
- if (typeof d.iwant[i] !== "object")
902
- throw TypeError(".ControlMessage.iwant: object expected");
903
- m.iwant[i] = $root.ControlIWant.fromObject(d.iwant[i]);
904
- }
905
- }
906
- if (d.graft) {
907
- if (!Array.isArray(d.graft))
908
- throw TypeError(".ControlMessage.graft: array expected");
909
- m.graft = [];
910
- for (var i = 0; i < d.graft.length; ++i) {
911
- if (typeof d.graft[i] !== "object")
912
- throw TypeError(".ControlMessage.graft: object expected");
913
- m.graft[i] = $root.ControlGraft.fromObject(d.graft[i]);
914
- }
915
- }
916
- if (d.prune) {
917
- if (!Array.isArray(d.prune))
918
- throw TypeError(".ControlMessage.prune: array expected");
919
- m.prune = [];
920
- for (var i = 0; i < d.prune.length; ++i) {
921
- if (typeof d.prune[i] !== "object")
922
- throw TypeError(".ControlMessage.prune: object expected");
923
- m.prune[i] = $root.ControlPrune.fromObject(d.prune[i]);
924
- }
925
- }
926
- return m;
927
- };
928
-
929
- /**
930
- * Creates a plain object from a ControlMessage message. Also converts values to other types if specified.
931
- * @function toObject
932
- * @memberof ControlMessage
933
- * @static
934
- * @param {ControlMessage} m ControlMessage
935
- * @param {$protobuf.IConversionOptions} [o] Conversion options
936
- * @returns {Object.<string,*>} Plain object
937
- */
938
- ControlMessage.toObject = function toObject(m, o) {
939
- if (!o)
940
- o = {};
941
- var d = {};
942
- if (o.arrays || o.defaults) {
943
- d.ihave = [];
944
- d.iwant = [];
945
- d.graft = [];
946
- d.prune = [];
947
- }
948
- if (m.ihave && m.ihave.length) {
949
- d.ihave = [];
950
- for (var j = 0; j < m.ihave.length; ++j) {
951
- d.ihave[j] = $root.ControlIHave.toObject(m.ihave[j], o);
952
- }
953
- }
954
- if (m.iwant && m.iwant.length) {
955
- d.iwant = [];
956
- for (var j = 0; j < m.iwant.length; ++j) {
957
- d.iwant[j] = $root.ControlIWant.toObject(m.iwant[j], o);
958
- }
959
- }
960
- if (m.graft && m.graft.length) {
961
- d.graft = [];
962
- for (var j = 0; j < m.graft.length; ++j) {
963
- d.graft[j] = $root.ControlGraft.toObject(m.graft[j], o);
964
- }
965
- }
966
- if (m.prune && m.prune.length) {
967
- d.prune = [];
968
- for (var j = 0; j < m.prune.length; ++j) {
969
- d.prune[j] = $root.ControlPrune.toObject(m.prune[j], o);
970
- }
971
- }
972
- return d;
973
- };
974
-
975
- /**
976
- * Converts this ControlMessage to JSON.
977
- * @function toJSON
978
- * @memberof ControlMessage
979
- * @instance
980
- * @returns {Object.<string,*>} JSON object
981
- */
982
- ControlMessage.prototype.toJSON = function toJSON() {
983
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
984
- };
985
-
986
- return ControlMessage;
987
- })();
988
-
989
- export const ControlIHave = $root.ControlIHave = (() => {
990
-
991
- /**
992
- * Properties of a ControlIHave.
993
- * @exports IControlIHave
994
- * @interface IControlIHave
995
- * @property {string|null} [topic] ControlIHave topic
996
- * @property {Array.<Uint8Array>|null} [messageIDs] ControlIHave messageIDs
997
- */
998
-
999
- /**
1000
- * Constructs a new ControlIHave.
1001
- * @exports ControlIHave
1002
- * @classdesc Represents a ControlIHave.
1003
- * @implements IControlIHave
1004
- * @constructor
1005
- * @param {IControlIHave=} [p] Properties to set
1006
- */
1007
- function ControlIHave(p) {
1008
- this.messageIDs = [];
1009
- if (p)
1010
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
1011
- if (p[ks[i]] != null)
1012
- this[ks[i]] = p[ks[i]];
1013
- }
1014
-
1015
- /**
1016
- * ControlIHave topic.
1017
- * @member {string|null|undefined} topic
1018
- * @memberof ControlIHave
1019
- * @instance
1020
- */
1021
- ControlIHave.prototype.topic = null;
1022
-
1023
- /**
1024
- * ControlIHave messageIDs.
1025
- * @member {Array.<Uint8Array>} messageIDs
1026
- * @memberof ControlIHave
1027
- * @instance
1028
- */
1029
- ControlIHave.prototype.messageIDs = $util.emptyArray;
1030
-
1031
- // OneOf field names bound to virtual getters and setters
1032
- let $oneOfFields;
1033
-
1034
- /**
1035
- * ControlIHave _topic.
1036
- * @member {"topic"|undefined} _topic
1037
- * @memberof ControlIHave
1038
- * @instance
1039
- */
1040
- Object.defineProperty(ControlIHave.prototype, "_topic", {
1041
- get: $util.oneOfGetter($oneOfFields = ["topic"]),
1042
- set: $util.oneOfSetter($oneOfFields)
1043
- });
1044
-
1045
- /**
1046
- * Encodes the specified ControlIHave message. Does not implicitly {@link ControlIHave.verify|verify} messages.
1047
- * @function encode
1048
- * @memberof ControlIHave
1049
- * @static
1050
- * @param {IControlIHave} m ControlIHave message or plain object to encode
1051
- * @param {$protobuf.Writer} [w] Writer to encode to
1052
- * @returns {$protobuf.Writer} Writer
1053
- */
1054
- ControlIHave.encode = function encode(m, w) {
1055
- if (!w)
1056
- w = $Writer.create();
1057
- if (m.topic != null && Object.hasOwnProperty.call(m, "topic"))
1058
- w.uint32(10).string(m.topic);
1059
- if (m.messageIDs != null && m.messageIDs.length) {
1060
- for (var i = 0; i < m.messageIDs.length; ++i)
1061
- w.uint32(18).bytes(m.messageIDs[i]);
1062
- }
1063
- return w;
1064
- };
1065
-
1066
- /**
1067
- * Decodes a ControlIHave message from the specified reader or buffer.
1068
- * @function decode
1069
- * @memberof ControlIHave
1070
- * @static
1071
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
1072
- * @param {number} [l] Message length if known beforehand
1073
- * @returns {ControlIHave} ControlIHave
1074
- * @throws {Error} If the payload is not a reader or valid buffer
1075
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
1076
- */
1077
- ControlIHave.decode = function decode(r, l) {
1078
- if (!(r instanceof $Reader))
1079
- r = $Reader.create(r);
1080
- var c = l === undefined ? r.len : r.pos + l, m = new $root.ControlIHave();
1081
- while (r.pos < c) {
1082
- var t = r.uint32();
1083
- switch (t >>> 3) {
1084
- case 1:
1085
- m.topic = r.string();
1086
- break;
1087
- case 2:
1088
- if (!(m.messageIDs && m.messageIDs.length))
1089
- m.messageIDs = [];
1090
- m.messageIDs.push(r.bytes());
1091
- break;
1092
- default:
1093
- r.skipType(t & 7);
1094
- break;
1095
- }
1096
- }
1097
- return m;
1098
- };
1099
-
1100
- /**
1101
- * Creates a ControlIHave message from a plain object. Also converts values to their respective internal types.
1102
- * @function fromObject
1103
- * @memberof ControlIHave
1104
- * @static
1105
- * @param {Object.<string,*>} d Plain object
1106
- * @returns {ControlIHave} ControlIHave
1107
- */
1108
- ControlIHave.fromObject = function fromObject(d) {
1109
- if (d instanceof $root.ControlIHave)
1110
- return d;
1111
- var m = new $root.ControlIHave();
1112
- if (d.topic != null) {
1113
- m.topic = String(d.topic);
1114
- }
1115
- if (d.messageIDs) {
1116
- if (!Array.isArray(d.messageIDs))
1117
- throw TypeError(".ControlIHave.messageIDs: array expected");
1118
- m.messageIDs = [];
1119
- for (var i = 0; i < d.messageIDs.length; ++i) {
1120
- if (typeof d.messageIDs[i] === "string")
1121
- $util.base64.decode(d.messageIDs[i], m.messageIDs[i] = $util.newBuffer($util.base64.length(d.messageIDs[i])), 0);
1122
- else if (d.messageIDs[i].length)
1123
- m.messageIDs[i] = d.messageIDs[i];
1124
- }
1125
- }
1126
- return m;
1127
- };
1128
-
1129
- /**
1130
- * Creates a plain object from a ControlIHave message. Also converts values to other types if specified.
1131
- * @function toObject
1132
- * @memberof ControlIHave
1133
- * @static
1134
- * @param {ControlIHave} m ControlIHave
1135
- * @param {$protobuf.IConversionOptions} [o] Conversion options
1136
- * @returns {Object.<string,*>} Plain object
1137
- */
1138
- ControlIHave.toObject = function toObject(m, o) {
1139
- if (!o)
1140
- o = {};
1141
- var d = {};
1142
- if (o.arrays || o.defaults) {
1143
- d.messageIDs = [];
1144
- }
1145
- if (m.topic != null && m.hasOwnProperty("topic")) {
1146
- d.topic = m.topic;
1147
- if (o.oneofs)
1148
- d._topic = "topic";
1149
- }
1150
- if (m.messageIDs && m.messageIDs.length) {
1151
- d.messageIDs = [];
1152
- for (var j = 0; j < m.messageIDs.length; ++j) {
1153
- d.messageIDs[j] = o.bytes === String ? $util.base64.encode(m.messageIDs[j], 0, m.messageIDs[j].length) : o.bytes === Array ? Array.prototype.slice.call(m.messageIDs[j]) : m.messageIDs[j];
1154
- }
1155
- }
1156
- return d;
1157
- };
1158
-
1159
- /**
1160
- * Converts this ControlIHave to JSON.
1161
- * @function toJSON
1162
- * @memberof ControlIHave
1163
- * @instance
1164
- * @returns {Object.<string,*>} JSON object
1165
- */
1166
- ControlIHave.prototype.toJSON = function toJSON() {
1167
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1168
- };
1169
-
1170
- return ControlIHave;
1171
- })();
1172
-
1173
- export const ControlIWant = $root.ControlIWant = (() => {
1174
-
1175
- /**
1176
- * Properties of a ControlIWant.
1177
- * @exports IControlIWant
1178
- * @interface IControlIWant
1179
- * @property {Array.<Uint8Array>|null} [messageIDs] ControlIWant messageIDs
1180
- */
1181
-
1182
- /**
1183
- * Constructs a new ControlIWant.
1184
- * @exports ControlIWant
1185
- * @classdesc Represents a ControlIWant.
1186
- * @implements IControlIWant
1187
- * @constructor
1188
- * @param {IControlIWant=} [p] Properties to set
1189
- */
1190
- function ControlIWant(p) {
1191
- this.messageIDs = [];
1192
- if (p)
1193
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
1194
- if (p[ks[i]] != null)
1195
- this[ks[i]] = p[ks[i]];
1196
- }
1197
-
1198
- /**
1199
- * ControlIWant messageIDs.
1200
- * @member {Array.<Uint8Array>} messageIDs
1201
- * @memberof ControlIWant
1202
- * @instance
1203
- */
1204
- ControlIWant.prototype.messageIDs = $util.emptyArray;
1205
-
1206
- /**
1207
- * Encodes the specified ControlIWant message. Does not implicitly {@link ControlIWant.verify|verify} messages.
1208
- * @function encode
1209
- * @memberof ControlIWant
1210
- * @static
1211
- * @param {IControlIWant} m ControlIWant message or plain object to encode
1212
- * @param {$protobuf.Writer} [w] Writer to encode to
1213
- * @returns {$protobuf.Writer} Writer
1214
- */
1215
- ControlIWant.encode = function encode(m, w) {
1216
- if (!w)
1217
- w = $Writer.create();
1218
- if (m.messageIDs != null && m.messageIDs.length) {
1219
- for (var i = 0; i < m.messageIDs.length; ++i)
1220
- w.uint32(10).bytes(m.messageIDs[i]);
1221
- }
1222
- return w;
1223
- };
1224
-
1225
- /**
1226
- * Decodes a ControlIWant message from the specified reader or buffer.
1227
- * @function decode
1228
- * @memberof ControlIWant
1229
- * @static
1230
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
1231
- * @param {number} [l] Message length if known beforehand
1232
- * @returns {ControlIWant} ControlIWant
1233
- * @throws {Error} If the payload is not a reader or valid buffer
1234
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
1235
- */
1236
- ControlIWant.decode = function decode(r, l) {
1237
- if (!(r instanceof $Reader))
1238
- r = $Reader.create(r);
1239
- var c = l === undefined ? r.len : r.pos + l, m = new $root.ControlIWant();
1240
- while (r.pos < c) {
1241
- var t = r.uint32();
1242
- switch (t >>> 3) {
1243
- case 1:
1244
- if (!(m.messageIDs && m.messageIDs.length))
1245
- m.messageIDs = [];
1246
- m.messageIDs.push(r.bytes());
1247
- break;
1248
- default:
1249
- r.skipType(t & 7);
1250
- break;
1251
- }
1252
- }
1253
- return m;
1254
- };
1255
-
1256
- /**
1257
- * Creates a ControlIWant message from a plain object. Also converts values to their respective internal types.
1258
- * @function fromObject
1259
- * @memberof ControlIWant
1260
- * @static
1261
- * @param {Object.<string,*>} d Plain object
1262
- * @returns {ControlIWant} ControlIWant
1263
- */
1264
- ControlIWant.fromObject = function fromObject(d) {
1265
- if (d instanceof $root.ControlIWant)
1266
- return d;
1267
- var m = new $root.ControlIWant();
1268
- if (d.messageIDs) {
1269
- if (!Array.isArray(d.messageIDs))
1270
- throw TypeError(".ControlIWant.messageIDs: array expected");
1271
- m.messageIDs = [];
1272
- for (var i = 0; i < d.messageIDs.length; ++i) {
1273
- if (typeof d.messageIDs[i] === "string")
1274
- $util.base64.decode(d.messageIDs[i], m.messageIDs[i] = $util.newBuffer($util.base64.length(d.messageIDs[i])), 0);
1275
- else if (d.messageIDs[i].length)
1276
- m.messageIDs[i] = d.messageIDs[i];
1277
- }
1278
- }
1279
- return m;
1280
- };
1281
-
1282
- /**
1283
- * Creates a plain object from a ControlIWant message. Also converts values to other types if specified.
1284
- * @function toObject
1285
- * @memberof ControlIWant
1286
- * @static
1287
- * @param {ControlIWant} m ControlIWant
1288
- * @param {$protobuf.IConversionOptions} [o] Conversion options
1289
- * @returns {Object.<string,*>} Plain object
1290
- */
1291
- ControlIWant.toObject = function toObject(m, o) {
1292
- if (!o)
1293
- o = {};
1294
- var d = {};
1295
- if (o.arrays || o.defaults) {
1296
- d.messageIDs = [];
1297
- }
1298
- if (m.messageIDs && m.messageIDs.length) {
1299
- d.messageIDs = [];
1300
- for (var j = 0; j < m.messageIDs.length; ++j) {
1301
- d.messageIDs[j] = o.bytes === String ? $util.base64.encode(m.messageIDs[j], 0, m.messageIDs[j].length) : o.bytes === Array ? Array.prototype.slice.call(m.messageIDs[j]) : m.messageIDs[j];
1302
- }
1303
- }
1304
- return d;
1305
- };
1306
-
1307
- /**
1308
- * Converts this ControlIWant to JSON.
1309
- * @function toJSON
1310
- * @memberof ControlIWant
1311
- * @instance
1312
- * @returns {Object.<string,*>} JSON object
1313
- */
1314
- ControlIWant.prototype.toJSON = function toJSON() {
1315
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1316
- };
1317
-
1318
- return ControlIWant;
1319
- })();
1320
-
1321
- export const ControlGraft = $root.ControlGraft = (() => {
1322
-
1323
- /**
1324
- * Properties of a ControlGraft.
1325
- * @exports IControlGraft
1326
- * @interface IControlGraft
1327
- * @property {string|null} [topic] ControlGraft topic
1328
- */
1329
-
1330
- /**
1331
- * Constructs a new ControlGraft.
1332
- * @exports ControlGraft
1333
- * @classdesc Represents a ControlGraft.
1334
- * @implements IControlGraft
1335
- * @constructor
1336
- * @param {IControlGraft=} [p] Properties to set
1337
- */
1338
- function ControlGraft(p) {
1339
- if (p)
1340
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
1341
- if (p[ks[i]] != null)
1342
- this[ks[i]] = p[ks[i]];
1343
- }
1344
-
1345
- /**
1346
- * ControlGraft topic.
1347
- * @member {string|null|undefined} topic
1348
- * @memberof ControlGraft
1349
- * @instance
1350
- */
1351
- ControlGraft.prototype.topic = null;
1352
-
1353
- // OneOf field names bound to virtual getters and setters
1354
- let $oneOfFields;
1355
-
1356
- /**
1357
- * ControlGraft _topic.
1358
- * @member {"topic"|undefined} _topic
1359
- * @memberof ControlGraft
1360
- * @instance
1361
- */
1362
- Object.defineProperty(ControlGraft.prototype, "_topic", {
1363
- get: $util.oneOfGetter($oneOfFields = ["topic"]),
1364
- set: $util.oneOfSetter($oneOfFields)
1365
- });
1366
-
1367
- /**
1368
- * Encodes the specified ControlGraft message. Does not implicitly {@link ControlGraft.verify|verify} messages.
1369
- * @function encode
1370
- * @memberof ControlGraft
1371
- * @static
1372
- * @param {IControlGraft} m ControlGraft message or plain object to encode
1373
- * @param {$protobuf.Writer} [w] Writer to encode to
1374
- * @returns {$protobuf.Writer} Writer
1375
- */
1376
- ControlGraft.encode = function encode(m, w) {
1377
- if (!w)
1378
- w = $Writer.create();
1379
- if (m.topic != null && Object.hasOwnProperty.call(m, "topic"))
1380
- w.uint32(10).string(m.topic);
1381
- return w;
1382
- };
1383
-
1384
- /**
1385
- * Decodes a ControlGraft message from the specified reader or buffer.
1386
- * @function decode
1387
- * @memberof ControlGraft
1388
- * @static
1389
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
1390
- * @param {number} [l] Message length if known beforehand
1391
- * @returns {ControlGraft} ControlGraft
1392
- * @throws {Error} If the payload is not a reader or valid buffer
1393
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
1394
- */
1395
- ControlGraft.decode = function decode(r, l) {
1396
- if (!(r instanceof $Reader))
1397
- r = $Reader.create(r);
1398
- var c = l === undefined ? r.len : r.pos + l, m = new $root.ControlGraft();
1399
- while (r.pos < c) {
1400
- var t = r.uint32();
1401
- switch (t >>> 3) {
1402
- case 1:
1403
- m.topic = r.string();
1404
- break;
1405
- default:
1406
- r.skipType(t & 7);
1407
- break;
1408
- }
1409
- }
1410
- return m;
1411
- };
1412
-
1413
- /**
1414
- * Creates a ControlGraft message from a plain object. Also converts values to their respective internal types.
1415
- * @function fromObject
1416
- * @memberof ControlGraft
1417
- * @static
1418
- * @param {Object.<string,*>} d Plain object
1419
- * @returns {ControlGraft} ControlGraft
1420
- */
1421
- ControlGraft.fromObject = function fromObject(d) {
1422
- if (d instanceof $root.ControlGraft)
1423
- return d;
1424
- var m = new $root.ControlGraft();
1425
- if (d.topic != null) {
1426
- m.topic = String(d.topic);
1427
- }
1428
- return m;
1429
- };
1430
-
1431
- /**
1432
- * Creates a plain object from a ControlGraft message. Also converts values to other types if specified.
1433
- * @function toObject
1434
- * @memberof ControlGraft
1435
- * @static
1436
- * @param {ControlGraft} m ControlGraft
1437
- * @param {$protobuf.IConversionOptions} [o] Conversion options
1438
- * @returns {Object.<string,*>} Plain object
1439
- */
1440
- ControlGraft.toObject = function toObject(m, o) {
1441
- if (!o)
1442
- o = {};
1443
- var d = {};
1444
- if (m.topic != null && m.hasOwnProperty("topic")) {
1445
- d.topic = m.topic;
1446
- if (o.oneofs)
1447
- d._topic = "topic";
1448
- }
1449
- return d;
1450
- };
1451
-
1452
- /**
1453
- * Converts this ControlGraft to JSON.
1454
- * @function toJSON
1455
- * @memberof ControlGraft
1456
- * @instance
1457
- * @returns {Object.<string,*>} JSON object
1458
- */
1459
- ControlGraft.prototype.toJSON = function toJSON() {
1460
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1461
- };
1462
-
1463
- return ControlGraft;
1464
- })();
1465
-
1466
- export const ControlPrune = $root.ControlPrune = (() => {
1467
-
1468
- /**
1469
- * Properties of a ControlPrune.
1470
- * @exports IControlPrune
1471
- * @interface IControlPrune
1472
- * @property {string|null} [topic] ControlPrune topic
1473
- * @property {Array.<IPeerInfo>|null} [peers] ControlPrune peers
1474
- * @property {number|null} [backoff] ControlPrune backoff
1475
- */
1476
-
1477
- /**
1478
- * Constructs a new ControlPrune.
1479
- * @exports ControlPrune
1480
- * @classdesc Represents a ControlPrune.
1481
- * @implements IControlPrune
1482
- * @constructor
1483
- * @param {IControlPrune=} [p] Properties to set
1484
- */
1485
- function ControlPrune(p) {
1486
- this.peers = [];
1487
- if (p)
1488
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
1489
- if (p[ks[i]] != null)
1490
- this[ks[i]] = p[ks[i]];
1491
- }
1492
-
1493
- /**
1494
- * ControlPrune topic.
1495
- * @member {string|null|undefined} topic
1496
- * @memberof ControlPrune
1497
- * @instance
1498
- */
1499
- ControlPrune.prototype.topic = null;
1500
-
1501
- /**
1502
- * ControlPrune peers.
1503
- * @member {Array.<IPeerInfo>} peers
1504
- * @memberof ControlPrune
1505
- * @instance
1506
- */
1507
- ControlPrune.prototype.peers = $util.emptyArray;
1508
-
1509
- /**
1510
- * ControlPrune backoff.
1511
- * @member {number|null|undefined} backoff
1512
- * @memberof ControlPrune
1513
- * @instance
1514
- */
1515
- ControlPrune.prototype.backoff = null;
1516
-
1517
- // OneOf field names bound to virtual getters and setters
1518
- let $oneOfFields;
1519
-
1520
- /**
1521
- * ControlPrune _topic.
1522
- * @member {"topic"|undefined} _topic
1523
- * @memberof ControlPrune
1524
- * @instance
1525
- */
1526
- Object.defineProperty(ControlPrune.prototype, "_topic", {
1527
- get: $util.oneOfGetter($oneOfFields = ["topic"]),
1528
- set: $util.oneOfSetter($oneOfFields)
1529
- });
1530
-
1531
- /**
1532
- * ControlPrune _backoff.
1533
- * @member {"backoff"|undefined} _backoff
1534
- * @memberof ControlPrune
1535
- * @instance
1536
- */
1537
- Object.defineProperty(ControlPrune.prototype, "_backoff", {
1538
- get: $util.oneOfGetter($oneOfFields = ["backoff"]),
1539
- set: $util.oneOfSetter($oneOfFields)
1540
- });
1541
-
1542
- /**
1543
- * Encodes the specified ControlPrune message. Does not implicitly {@link ControlPrune.verify|verify} messages.
1544
- * @function encode
1545
- * @memberof ControlPrune
1546
- * @static
1547
- * @param {IControlPrune} m ControlPrune message or plain object to encode
1548
- * @param {$protobuf.Writer} [w] Writer to encode to
1549
- * @returns {$protobuf.Writer} Writer
1550
- */
1551
- ControlPrune.encode = function encode(m, w) {
1552
- if (!w)
1553
- w = $Writer.create();
1554
- if (m.topic != null && Object.hasOwnProperty.call(m, "topic"))
1555
- w.uint32(10).string(m.topic);
1556
- if (m.peers != null && m.peers.length) {
1557
- for (var i = 0; i < m.peers.length; ++i)
1558
- $root.PeerInfo.encode(m.peers[i], w.uint32(18).fork()).ldelim();
1559
- }
1560
- if (m.backoff != null && Object.hasOwnProperty.call(m, "backoff"))
1561
- w.uint32(24).uint64(m.backoff);
1562
- return w;
1563
- };
1564
-
1565
- /**
1566
- * Decodes a ControlPrune message from the specified reader or buffer.
1567
- * @function decode
1568
- * @memberof ControlPrune
1569
- * @static
1570
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
1571
- * @param {number} [l] Message length if known beforehand
1572
- * @returns {ControlPrune} ControlPrune
1573
- * @throws {Error} If the payload is not a reader or valid buffer
1574
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
1575
- */
1576
- ControlPrune.decode = function decode(r, l) {
1577
- if (!(r instanceof $Reader))
1578
- r = $Reader.create(r);
1579
- var c = l === undefined ? r.len : r.pos + l, m = new $root.ControlPrune();
1580
- while (r.pos < c) {
1581
- var t = r.uint32();
1582
- switch (t >>> 3) {
1583
- case 1:
1584
- m.topic = r.string();
1585
- break;
1586
- case 2:
1587
- if (!(m.peers && m.peers.length))
1588
- m.peers = [];
1589
- m.peers.push($root.PeerInfo.decode(r, r.uint32()));
1590
- break;
1591
- case 3:
1592
- m.backoff = r.uint64();
1593
- break;
1594
- default:
1595
- r.skipType(t & 7);
1596
- break;
1597
- }
1598
- }
1599
- return m;
1600
- };
1601
-
1602
- /**
1603
- * Creates a ControlPrune message from a plain object. Also converts values to their respective internal types.
1604
- * @function fromObject
1605
- * @memberof ControlPrune
1606
- * @static
1607
- * @param {Object.<string,*>} d Plain object
1608
- * @returns {ControlPrune} ControlPrune
1609
- */
1610
- ControlPrune.fromObject = function fromObject(d) {
1611
- if (d instanceof $root.ControlPrune)
1612
- return d;
1613
- var m = new $root.ControlPrune();
1614
- if (d.topic != null) {
1615
- m.topic = String(d.topic);
1616
- }
1617
- if (d.peers) {
1618
- if (!Array.isArray(d.peers))
1619
- throw TypeError(".ControlPrune.peers: array expected");
1620
- m.peers = [];
1621
- for (var i = 0; i < d.peers.length; ++i) {
1622
- if (typeof d.peers[i] !== "object")
1623
- throw TypeError(".ControlPrune.peers: object expected");
1624
- m.peers[i] = $root.PeerInfo.fromObject(d.peers[i]);
1625
- }
1626
- }
1627
- if (d.backoff != null) {
1628
- if ($util.Long)
1629
- (m.backoff = $util.Long.fromValue(d.backoff)).unsigned = true;
1630
- else if (typeof d.backoff === "string")
1631
- m.backoff = parseInt(d.backoff, 10);
1632
- else if (typeof d.backoff === "number")
1633
- m.backoff = d.backoff;
1634
- else if (typeof d.backoff === "object")
1635
- m.backoff = new $util.LongBits(d.backoff.low >>> 0, d.backoff.high >>> 0).toNumber(true);
1636
- }
1637
- return m;
1638
- };
1639
-
1640
- /**
1641
- * Creates a plain object from a ControlPrune message. Also converts values to other types if specified.
1642
- * @function toObject
1643
- * @memberof ControlPrune
1644
- * @static
1645
- * @param {ControlPrune} m ControlPrune
1646
- * @param {$protobuf.IConversionOptions} [o] Conversion options
1647
- * @returns {Object.<string,*>} Plain object
1648
- */
1649
- ControlPrune.toObject = function toObject(m, o) {
1650
- if (!o)
1651
- o = {};
1652
- var d = {};
1653
- if (o.arrays || o.defaults) {
1654
- d.peers = [];
1655
- }
1656
- if (m.topic != null && m.hasOwnProperty("topic")) {
1657
- d.topic = m.topic;
1658
- if (o.oneofs)
1659
- d._topic = "topic";
1660
- }
1661
- if (m.peers && m.peers.length) {
1662
- d.peers = [];
1663
- for (var j = 0; j < m.peers.length; ++j) {
1664
- d.peers[j] = $root.PeerInfo.toObject(m.peers[j], o);
1665
- }
1666
- }
1667
- if (m.backoff != null && m.hasOwnProperty("backoff")) {
1668
- if (typeof m.backoff === "number")
1669
- d.backoff = o.longs === String ? String(m.backoff) : m.backoff;
1670
- else
1671
- d.backoff = o.longs === String ? $util.Long.prototype.toString.call(m.backoff) : o.longs === Number ? new $util.LongBits(m.backoff.low >>> 0, m.backoff.high >>> 0).toNumber(true) : m.backoff;
1672
- if (o.oneofs)
1673
- d._backoff = "backoff";
1674
- }
1675
- return d;
1676
- };
1677
-
1678
- /**
1679
- * Converts this ControlPrune to JSON.
1680
- * @function toJSON
1681
- * @memberof ControlPrune
1682
- * @instance
1683
- * @returns {Object.<string,*>} JSON object
1684
- */
1685
- ControlPrune.prototype.toJSON = function toJSON() {
1686
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1687
- };
1688
-
1689
- return ControlPrune;
1690
- })();
1691
-
1692
- export const PeerInfo = $root.PeerInfo = (() => {
1693
-
1694
- /**
1695
- * Properties of a PeerInfo.
1696
- * @exports IPeerInfo
1697
- * @interface IPeerInfo
1698
- * @property {Uint8Array|null} [peerID] PeerInfo peerID
1699
- * @property {Uint8Array|null} [signedPeerRecord] PeerInfo signedPeerRecord
1700
- */
1701
-
1702
- /**
1703
- * Constructs a new PeerInfo.
1704
- * @exports PeerInfo
1705
- * @classdesc Represents a PeerInfo.
1706
- * @implements IPeerInfo
1707
- * @constructor
1708
- * @param {IPeerInfo=} [p] Properties to set
1709
- */
1710
- function PeerInfo(p) {
1711
- if (p)
1712
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
1713
- if (p[ks[i]] != null)
1714
- this[ks[i]] = p[ks[i]];
1715
- }
1716
-
1717
- /**
1718
- * PeerInfo peerID.
1719
- * @member {Uint8Array|null|undefined} peerID
1720
- * @memberof PeerInfo
1721
- * @instance
1722
- */
1723
- PeerInfo.prototype.peerID = null;
1724
-
1725
- /**
1726
- * PeerInfo signedPeerRecord.
1727
- * @member {Uint8Array|null|undefined} signedPeerRecord
1728
- * @memberof PeerInfo
1729
- * @instance
1730
- */
1731
- PeerInfo.prototype.signedPeerRecord = null;
1732
-
1733
- // OneOf field names bound to virtual getters and setters
1734
- let $oneOfFields;
1735
-
1736
- /**
1737
- * PeerInfo _peerID.
1738
- * @member {"peerID"|undefined} _peerID
1739
- * @memberof PeerInfo
1740
- * @instance
1741
- */
1742
- Object.defineProperty(PeerInfo.prototype, "_peerID", {
1743
- get: $util.oneOfGetter($oneOfFields = ["peerID"]),
1744
- set: $util.oneOfSetter($oneOfFields)
1745
- });
1746
-
1747
- /**
1748
- * PeerInfo _signedPeerRecord.
1749
- * @member {"signedPeerRecord"|undefined} _signedPeerRecord
1750
- * @memberof PeerInfo
1751
- * @instance
1752
- */
1753
- Object.defineProperty(PeerInfo.prototype, "_signedPeerRecord", {
1754
- get: $util.oneOfGetter($oneOfFields = ["signedPeerRecord"]),
1755
- set: $util.oneOfSetter($oneOfFields)
1756
- });
1757
-
1758
- /**
1759
- * Encodes the specified PeerInfo message. Does not implicitly {@link PeerInfo.verify|verify} messages.
1760
- * @function encode
1761
- * @memberof PeerInfo
1762
- * @static
1763
- * @param {IPeerInfo} m PeerInfo message or plain object to encode
1764
- * @param {$protobuf.Writer} [w] Writer to encode to
1765
- * @returns {$protobuf.Writer} Writer
1766
- */
1767
- PeerInfo.encode = function encode(m, w) {
1768
- if (!w)
1769
- w = $Writer.create();
1770
- if (m.peerID != null && Object.hasOwnProperty.call(m, "peerID"))
1771
- w.uint32(10).bytes(m.peerID);
1772
- if (m.signedPeerRecord != null && Object.hasOwnProperty.call(m, "signedPeerRecord"))
1773
- w.uint32(18).bytes(m.signedPeerRecord);
1774
- return w;
1775
- };
1776
-
1777
- /**
1778
- * Decodes a PeerInfo message from the specified reader or buffer.
1779
- * @function decode
1780
- * @memberof PeerInfo
1781
- * @static
1782
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
1783
- * @param {number} [l] Message length if known beforehand
1784
- * @returns {PeerInfo} PeerInfo
1785
- * @throws {Error} If the payload is not a reader or valid buffer
1786
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
1787
- */
1788
- PeerInfo.decode = function decode(r, l) {
1789
- if (!(r instanceof $Reader))
1790
- r = $Reader.create(r);
1791
- var c = l === undefined ? r.len : r.pos + l, m = new $root.PeerInfo();
1792
- while (r.pos < c) {
1793
- var t = r.uint32();
1794
- switch (t >>> 3) {
1795
- case 1:
1796
- m.peerID = r.bytes();
1797
- break;
1798
- case 2:
1799
- m.signedPeerRecord = r.bytes();
1800
- break;
1801
- default:
1802
- r.skipType(t & 7);
1803
- break;
1804
- }
1805
- }
1806
- return m;
1807
- };
1808
-
1809
- /**
1810
- * Creates a PeerInfo message from a plain object. Also converts values to their respective internal types.
1811
- * @function fromObject
1812
- * @memberof PeerInfo
1813
- * @static
1814
- * @param {Object.<string,*>} d Plain object
1815
- * @returns {PeerInfo} PeerInfo
1816
- */
1817
- PeerInfo.fromObject = function fromObject(d) {
1818
- if (d instanceof $root.PeerInfo)
1819
- return d;
1820
- var m = new $root.PeerInfo();
1821
- if (d.peerID != null) {
1822
- if (typeof d.peerID === "string")
1823
- $util.base64.decode(d.peerID, m.peerID = $util.newBuffer($util.base64.length(d.peerID)), 0);
1824
- else if (d.peerID.length)
1825
- m.peerID = d.peerID;
1826
- }
1827
- if (d.signedPeerRecord != null) {
1828
- if (typeof d.signedPeerRecord === "string")
1829
- $util.base64.decode(d.signedPeerRecord, m.signedPeerRecord = $util.newBuffer($util.base64.length(d.signedPeerRecord)), 0);
1830
- else if (d.signedPeerRecord.length)
1831
- m.signedPeerRecord = d.signedPeerRecord;
1832
- }
1833
- return m;
1834
- };
1835
-
1836
- /**
1837
- * Creates a plain object from a PeerInfo message. Also converts values to other types if specified.
1838
- * @function toObject
1839
- * @memberof PeerInfo
1840
- * @static
1841
- * @param {PeerInfo} m PeerInfo
1842
- * @param {$protobuf.IConversionOptions} [o] Conversion options
1843
- * @returns {Object.<string,*>} Plain object
1844
- */
1845
- PeerInfo.toObject = function toObject(m, o) {
1846
- if (!o)
1847
- o = {};
1848
- var d = {};
1849
- if (m.peerID != null && m.hasOwnProperty("peerID")) {
1850
- d.peerID = o.bytes === String ? $util.base64.encode(m.peerID, 0, m.peerID.length) : o.bytes === Array ? Array.prototype.slice.call(m.peerID) : m.peerID;
1851
- if (o.oneofs)
1852
- d._peerID = "peerID";
1853
- }
1854
- if (m.signedPeerRecord != null && m.hasOwnProperty("signedPeerRecord")) {
1855
- d.signedPeerRecord = o.bytes === String ? $util.base64.encode(m.signedPeerRecord, 0, m.signedPeerRecord.length) : o.bytes === Array ? Array.prototype.slice.call(m.signedPeerRecord) : m.signedPeerRecord;
1856
- if (o.oneofs)
1857
- d._signedPeerRecord = "signedPeerRecord";
1858
- }
1859
- return d;
1860
- };
1861
-
1862
- /**
1863
- * Converts this PeerInfo to JSON.
1864
- * @function toJSON
1865
- * @memberof PeerInfo
1866
- * @instance
1867
- * @returns {Object.<string,*>} JSON object
1868
- */
1869
- PeerInfo.prototype.toJSON = function toJSON() {
1870
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1871
- };
1872
-
1873
- return PeerInfo;
1874
- })();
1875
-
1876
- export { $root as default };