@libp2p/floodsub 11.0.14 → 11.0.15
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.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/message/rpc.d.ts +223 -18
- package/dist/src/message/rpc.d.ts.map +1 -1
- package/dist/src/message/rpc.js +460 -56
- package/dist/src/message/rpc.js.map +1 -1
- package/package.json +10 -10
- package/src/message/rpc.ts +713 -39
package/dist/src/message/rpc.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { decodeMessage, encodeMessage, MaxLengthError, message } from 'protons-runtime';
|
|
1
|
+
import { decodeMessage, encodeMessage, MaxLengthError, message, streamMessage } from 'protons-runtime';
|
|
3
2
|
export var RPC;
|
|
4
3
|
(function (RPC) {
|
|
5
4
|
let SubOpts;
|
|
@@ -43,16 +42,47 @@ export var RPC;
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
return obj;
|
|
45
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
46
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
47
|
+
while (reader.pos < end) {
|
|
48
|
+
const tag = reader.uint32();
|
|
49
|
+
switch (tag >>> 3) {
|
|
50
|
+
case 1: {
|
|
51
|
+
yield {
|
|
52
|
+
field: `${prefix}.subscribe`,
|
|
53
|
+
value: reader.bool()
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 2: {
|
|
58
|
+
yield {
|
|
59
|
+
field: `${prefix}.topic`,
|
|
60
|
+
value: reader.string()
|
|
61
|
+
};
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
default: {
|
|
65
|
+
reader.skipType(tag & 7);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
46
70
|
});
|
|
47
71
|
}
|
|
48
72
|
return _codec;
|
|
49
73
|
};
|
|
50
|
-
|
|
74
|
+
function encode(obj) {
|
|
51
75
|
return encodeMessage(obj, SubOpts.codec());
|
|
52
|
-
}
|
|
53
|
-
SubOpts.
|
|
76
|
+
}
|
|
77
|
+
SubOpts.encode = encode;
|
|
78
|
+
function decode(buf, opts) {
|
|
54
79
|
return decodeMessage(buf, SubOpts.codec(), opts);
|
|
55
|
-
}
|
|
80
|
+
}
|
|
81
|
+
SubOpts.decode = decode;
|
|
82
|
+
function stream(buf, opts) {
|
|
83
|
+
return streamMessage(buf, SubOpts.codec(), opts);
|
|
84
|
+
}
|
|
85
|
+
SubOpts.stream = stream;
|
|
56
86
|
})(SubOpts = RPC.SubOpts || (RPC.SubOpts = {}));
|
|
57
87
|
let Message;
|
|
58
88
|
(function (Message) {
|
|
@@ -127,16 +157,75 @@ export var RPC;
|
|
|
127
157
|
}
|
|
128
158
|
}
|
|
129
159
|
return obj;
|
|
160
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
161
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
162
|
+
while (reader.pos < end) {
|
|
163
|
+
const tag = reader.uint32();
|
|
164
|
+
switch (tag >>> 3) {
|
|
165
|
+
case 1: {
|
|
166
|
+
yield {
|
|
167
|
+
field: `${prefix}.from`,
|
|
168
|
+
value: reader.bytes()
|
|
169
|
+
};
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
case 2: {
|
|
173
|
+
yield {
|
|
174
|
+
field: `${prefix}.data`,
|
|
175
|
+
value: reader.bytes()
|
|
176
|
+
};
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case 3: {
|
|
180
|
+
yield {
|
|
181
|
+
field: `${prefix}.sequenceNumber`,
|
|
182
|
+
value: reader.bytes()
|
|
183
|
+
};
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case 4: {
|
|
187
|
+
yield {
|
|
188
|
+
field: `${prefix}.topic`,
|
|
189
|
+
value: reader.string()
|
|
190
|
+
};
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case 5: {
|
|
194
|
+
yield {
|
|
195
|
+
field: `${prefix}.signature`,
|
|
196
|
+
value: reader.bytes()
|
|
197
|
+
};
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case 6: {
|
|
201
|
+
yield {
|
|
202
|
+
field: `${prefix}.key`,
|
|
203
|
+
value: reader.bytes()
|
|
204
|
+
};
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
default: {
|
|
208
|
+
reader.skipType(tag & 7);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
130
213
|
});
|
|
131
214
|
}
|
|
132
215
|
return _codec;
|
|
133
216
|
};
|
|
134
|
-
|
|
217
|
+
function encode(obj) {
|
|
135
218
|
return encodeMessage(obj, Message.codec());
|
|
136
|
-
}
|
|
137
|
-
Message.
|
|
219
|
+
}
|
|
220
|
+
Message.encode = encode;
|
|
221
|
+
function decode(buf, opts) {
|
|
138
222
|
return decodeMessage(buf, Message.codec(), opts);
|
|
139
|
-
}
|
|
223
|
+
}
|
|
224
|
+
Message.decode = decode;
|
|
225
|
+
function stream(buf, opts) {
|
|
226
|
+
return streamMessage(buf, Message.codec(), opts);
|
|
227
|
+
}
|
|
228
|
+
Message.stream = stream;
|
|
140
229
|
})(Message = RPC.Message || (RPC.Message = {}));
|
|
141
230
|
let _codec;
|
|
142
231
|
RPC.codec = () => {
|
|
@@ -145,13 +234,13 @@ export var RPC;
|
|
|
145
234
|
if (opts.lengthDelimited !== false) {
|
|
146
235
|
w.fork();
|
|
147
236
|
}
|
|
148
|
-
if (obj.subscriptions != null) {
|
|
237
|
+
if (obj.subscriptions != null && obj.subscriptions.length > 0) {
|
|
149
238
|
for (const value of obj.subscriptions) {
|
|
150
239
|
w.uint32(10);
|
|
151
240
|
RPC.SubOpts.codec().encode(value, w);
|
|
152
241
|
}
|
|
153
242
|
}
|
|
154
|
-
if (obj.messages != null) {
|
|
243
|
+
if (obj.messages != null && obj.messages.length > 0) {
|
|
155
244
|
for (const value of obj.messages) {
|
|
156
245
|
w.uint32(18);
|
|
157
246
|
RPC.Message.codec().encode(value, w);
|
|
@@ -175,7 +264,7 @@ export var RPC;
|
|
|
175
264
|
switch (tag >>> 3) {
|
|
176
265
|
case 1: {
|
|
177
266
|
if (opts.limits?.subscriptions != null && obj.subscriptions.length === opts.limits.subscriptions) {
|
|
178
|
-
throw new MaxLengthError('Decode error -
|
|
267
|
+
throw new MaxLengthError('Decode error - repeated field "subscriptions" had too many elements');
|
|
179
268
|
}
|
|
180
269
|
obj.subscriptions.push(RPC.SubOpts.codec().decode(reader, reader.uint32(), {
|
|
181
270
|
limits: opts.limits?.subscriptions$
|
|
@@ -184,7 +273,7 @@ export var RPC;
|
|
|
184
273
|
}
|
|
185
274
|
case 2: {
|
|
186
275
|
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
|
|
187
|
-
throw new MaxLengthError('Decode error -
|
|
276
|
+
throw new MaxLengthError('Decode error - repeated field "messages" had too many elements');
|
|
188
277
|
}
|
|
189
278
|
obj.messages.push(RPC.Message.codec().decode(reader, reader.uint32(), {
|
|
190
279
|
limits: opts.limits?.messages$
|
|
@@ -204,16 +293,73 @@ export var RPC;
|
|
|
204
293
|
}
|
|
205
294
|
}
|
|
206
295
|
return obj;
|
|
296
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
297
|
+
const obj = {
|
|
298
|
+
subscriptions: 0,
|
|
299
|
+
messages: 0
|
|
300
|
+
};
|
|
301
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
302
|
+
while (reader.pos < end) {
|
|
303
|
+
const tag = reader.uint32();
|
|
304
|
+
switch (tag >>> 3) {
|
|
305
|
+
case 1: {
|
|
306
|
+
if (opts.limits?.subscriptions != null && obj.subscriptions === opts.limits.subscriptions) {
|
|
307
|
+
throw new MaxLengthError('Streaming decode error - repeated field "subscriptions" had too many elements');
|
|
308
|
+
}
|
|
309
|
+
for (const evt of RPC.SubOpts.codec().stream(reader, reader.uint32(), `${prefix}.subscriptions[]`, {
|
|
310
|
+
limits: opts.limits?.subscriptions$
|
|
311
|
+
})) {
|
|
312
|
+
yield {
|
|
313
|
+
...evt,
|
|
314
|
+
index: obj.subscriptions
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
obj.subscriptions++;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
case 2: {
|
|
321
|
+
if (opts.limits?.messages != null && obj.messages === opts.limits.messages) {
|
|
322
|
+
throw new MaxLengthError('Streaming decode error - repeated field "messages" had too many elements');
|
|
323
|
+
}
|
|
324
|
+
for (const evt of RPC.Message.codec().stream(reader, reader.uint32(), `${prefix}.messages[]`, {
|
|
325
|
+
limits: opts.limits?.messages$
|
|
326
|
+
})) {
|
|
327
|
+
yield {
|
|
328
|
+
...evt,
|
|
329
|
+
index: obj.messages
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
obj.messages++;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
case 3: {
|
|
336
|
+
yield* ControlMessage.codec().stream(reader, reader.uint32(), `${prefix}.control`, {
|
|
337
|
+
limits: opts.limits?.control
|
|
338
|
+
});
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
default: {
|
|
342
|
+
reader.skipType(tag & 7);
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
207
347
|
});
|
|
208
348
|
}
|
|
209
349
|
return _codec;
|
|
210
350
|
};
|
|
211
|
-
|
|
351
|
+
function encode(obj) {
|
|
212
352
|
return encodeMessage(obj, RPC.codec());
|
|
213
|
-
}
|
|
214
|
-
RPC.
|
|
353
|
+
}
|
|
354
|
+
RPC.encode = encode;
|
|
355
|
+
function decode(buf, opts) {
|
|
215
356
|
return decodeMessage(buf, RPC.codec(), opts);
|
|
216
|
-
}
|
|
357
|
+
}
|
|
358
|
+
RPC.decode = decode;
|
|
359
|
+
function stream(buf, opts) {
|
|
360
|
+
return streamMessage(buf, RPC.codec(), opts);
|
|
361
|
+
}
|
|
362
|
+
RPC.stream = stream;
|
|
217
363
|
})(RPC || (RPC = {}));
|
|
218
364
|
export var ControlMessage;
|
|
219
365
|
(function (ControlMessage) {
|
|
@@ -224,25 +370,25 @@ export var ControlMessage;
|
|
|
224
370
|
if (opts.lengthDelimited !== false) {
|
|
225
371
|
w.fork();
|
|
226
372
|
}
|
|
227
|
-
if (obj.ihave != null) {
|
|
373
|
+
if (obj.ihave != null && obj.ihave.length > 0) {
|
|
228
374
|
for (const value of obj.ihave) {
|
|
229
375
|
w.uint32(10);
|
|
230
376
|
ControlIHave.codec().encode(value, w);
|
|
231
377
|
}
|
|
232
378
|
}
|
|
233
|
-
if (obj.iwant != null) {
|
|
379
|
+
if (obj.iwant != null && obj.iwant.length > 0) {
|
|
234
380
|
for (const value of obj.iwant) {
|
|
235
381
|
w.uint32(18);
|
|
236
382
|
ControlIWant.codec().encode(value, w);
|
|
237
383
|
}
|
|
238
384
|
}
|
|
239
|
-
if (obj.graft != null) {
|
|
385
|
+
if (obj.graft != null && obj.graft.length > 0) {
|
|
240
386
|
for (const value of obj.graft) {
|
|
241
387
|
w.uint32(26);
|
|
242
388
|
ControlGraft.codec().encode(value, w);
|
|
243
389
|
}
|
|
244
390
|
}
|
|
245
|
-
if (obj.prune != null) {
|
|
391
|
+
if (obj.prune != null && obj.prune.length > 0) {
|
|
246
392
|
for (const value of obj.prune) {
|
|
247
393
|
w.uint32(34);
|
|
248
394
|
ControlPrune.codec().encode(value, w);
|
|
@@ -264,7 +410,7 @@ export var ControlMessage;
|
|
|
264
410
|
switch (tag >>> 3) {
|
|
265
411
|
case 1: {
|
|
266
412
|
if (opts.limits?.ihave != null && obj.ihave.length === opts.limits.ihave) {
|
|
267
|
-
throw new MaxLengthError('Decode error -
|
|
413
|
+
throw new MaxLengthError('Decode error - repeated field "ihave" had too many elements');
|
|
268
414
|
}
|
|
269
415
|
obj.ihave.push(ControlIHave.codec().decode(reader, reader.uint32(), {
|
|
270
416
|
limits: opts.limits?.ihave$
|
|
@@ -273,7 +419,7 @@ export var ControlMessage;
|
|
|
273
419
|
}
|
|
274
420
|
case 2: {
|
|
275
421
|
if (opts.limits?.iwant != null && obj.iwant.length === opts.limits.iwant) {
|
|
276
|
-
throw new MaxLengthError('Decode error -
|
|
422
|
+
throw new MaxLengthError('Decode error - repeated field "iwant" had too many elements');
|
|
277
423
|
}
|
|
278
424
|
obj.iwant.push(ControlIWant.codec().decode(reader, reader.uint32(), {
|
|
279
425
|
limits: opts.limits?.iwant$
|
|
@@ -282,7 +428,7 @@ export var ControlMessage;
|
|
|
282
428
|
}
|
|
283
429
|
case 3: {
|
|
284
430
|
if (opts.limits?.graft != null && obj.graft.length === opts.limits.graft) {
|
|
285
|
-
throw new MaxLengthError('Decode error -
|
|
431
|
+
throw new MaxLengthError('Decode error - repeated field "graft" had too many elements');
|
|
286
432
|
}
|
|
287
433
|
obj.graft.push(ControlGraft.codec().decode(reader, reader.uint32(), {
|
|
288
434
|
limits: opts.limits?.graft$
|
|
@@ -291,7 +437,7 @@ export var ControlMessage;
|
|
|
291
437
|
}
|
|
292
438
|
case 4: {
|
|
293
439
|
if (opts.limits?.prune != null && obj.prune.length === opts.limits.prune) {
|
|
294
|
-
throw new MaxLengthError('Decode error -
|
|
440
|
+
throw new MaxLengthError('Decode error - repeated field "prune" had too many elements');
|
|
295
441
|
}
|
|
296
442
|
obj.prune.push(ControlPrune.codec().decode(reader, reader.uint32(), {
|
|
297
443
|
limits: opts.limits?.prune$
|
|
@@ -305,16 +451,99 @@ export var ControlMessage;
|
|
|
305
451
|
}
|
|
306
452
|
}
|
|
307
453
|
return obj;
|
|
454
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
455
|
+
const obj = {
|
|
456
|
+
ihave: 0,
|
|
457
|
+
iwant: 0,
|
|
458
|
+
graft: 0,
|
|
459
|
+
prune: 0
|
|
460
|
+
};
|
|
461
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
462
|
+
while (reader.pos < end) {
|
|
463
|
+
const tag = reader.uint32();
|
|
464
|
+
switch (tag >>> 3) {
|
|
465
|
+
case 1: {
|
|
466
|
+
if (opts.limits?.ihave != null && obj.ihave === opts.limits.ihave) {
|
|
467
|
+
throw new MaxLengthError('Streaming decode error - repeated field "ihave" had too many elements');
|
|
468
|
+
}
|
|
469
|
+
for (const evt of ControlIHave.codec().stream(reader, reader.uint32(), `${prefix}.ihave[]`, {
|
|
470
|
+
limits: opts.limits?.ihave$
|
|
471
|
+
})) {
|
|
472
|
+
yield {
|
|
473
|
+
...evt,
|
|
474
|
+
index: obj.ihave
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
obj.ihave++;
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
case 2: {
|
|
481
|
+
if (opts.limits?.iwant != null && obj.iwant === opts.limits.iwant) {
|
|
482
|
+
throw new MaxLengthError('Streaming decode error - repeated field "iwant" had too many elements');
|
|
483
|
+
}
|
|
484
|
+
for (const evt of ControlIWant.codec().stream(reader, reader.uint32(), `${prefix}.iwant[]`, {
|
|
485
|
+
limits: opts.limits?.iwant$
|
|
486
|
+
})) {
|
|
487
|
+
yield {
|
|
488
|
+
...evt,
|
|
489
|
+
index: obj.iwant
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
obj.iwant++;
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
case 3: {
|
|
496
|
+
if (opts.limits?.graft != null && obj.graft === opts.limits.graft) {
|
|
497
|
+
throw new MaxLengthError('Streaming decode error - repeated field "graft" had too many elements');
|
|
498
|
+
}
|
|
499
|
+
for (const evt of ControlGraft.codec().stream(reader, reader.uint32(), `${prefix}.graft[]`, {
|
|
500
|
+
limits: opts.limits?.graft$
|
|
501
|
+
})) {
|
|
502
|
+
yield {
|
|
503
|
+
...evt,
|
|
504
|
+
index: obj.graft
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
obj.graft++;
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
case 4: {
|
|
511
|
+
if (opts.limits?.prune != null && obj.prune === opts.limits.prune) {
|
|
512
|
+
throw new MaxLengthError('Streaming decode error - repeated field "prune" had too many elements');
|
|
513
|
+
}
|
|
514
|
+
for (const evt of ControlPrune.codec().stream(reader, reader.uint32(), `${prefix}.prune[]`, {
|
|
515
|
+
limits: opts.limits?.prune$
|
|
516
|
+
})) {
|
|
517
|
+
yield {
|
|
518
|
+
...evt,
|
|
519
|
+
index: obj.prune
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
obj.prune++;
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
default: {
|
|
526
|
+
reader.skipType(tag & 7);
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
308
531
|
});
|
|
309
532
|
}
|
|
310
533
|
return _codec;
|
|
311
534
|
};
|
|
312
|
-
|
|
535
|
+
function encode(obj) {
|
|
313
536
|
return encodeMessage(obj, ControlMessage.codec());
|
|
314
|
-
}
|
|
315
|
-
ControlMessage.
|
|
537
|
+
}
|
|
538
|
+
ControlMessage.encode = encode;
|
|
539
|
+
function decode(buf, opts) {
|
|
316
540
|
return decodeMessage(buf, ControlMessage.codec(), opts);
|
|
317
|
-
}
|
|
541
|
+
}
|
|
542
|
+
ControlMessage.decode = decode;
|
|
543
|
+
function stream(buf, opts) {
|
|
544
|
+
return streamMessage(buf, ControlMessage.codec(), opts);
|
|
545
|
+
}
|
|
546
|
+
ControlMessage.stream = stream;
|
|
318
547
|
})(ControlMessage || (ControlMessage = {}));
|
|
319
548
|
export var ControlIHave;
|
|
320
549
|
(function (ControlIHave) {
|
|
@@ -329,7 +558,7 @@ export var ControlIHave;
|
|
|
329
558
|
w.uint32(10);
|
|
330
559
|
w.string(obj.topic);
|
|
331
560
|
}
|
|
332
|
-
if (obj.messageIDs != null) {
|
|
561
|
+
if (obj.messageIDs != null && obj.messageIDs.length > 0) {
|
|
333
562
|
for (const value of obj.messageIDs) {
|
|
334
563
|
w.uint32(18);
|
|
335
564
|
w.bytes(value);
|
|
@@ -352,7 +581,7 @@ export var ControlIHave;
|
|
|
352
581
|
}
|
|
353
582
|
case 2: {
|
|
354
583
|
if (opts.limits?.messageIDs != null && obj.messageIDs.length === opts.limits.messageIDs) {
|
|
355
|
-
throw new MaxLengthError('Decode error -
|
|
584
|
+
throw new MaxLengthError('Decode error - repeated field "messageIDs" had too many elements');
|
|
356
585
|
}
|
|
357
586
|
obj.messageIDs.push(reader.bytes());
|
|
358
587
|
break;
|
|
@@ -364,16 +593,55 @@ export var ControlIHave;
|
|
|
364
593
|
}
|
|
365
594
|
}
|
|
366
595
|
return obj;
|
|
596
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
597
|
+
const obj = {
|
|
598
|
+
messageIDs: 0
|
|
599
|
+
};
|
|
600
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
601
|
+
while (reader.pos < end) {
|
|
602
|
+
const tag = reader.uint32();
|
|
603
|
+
switch (tag >>> 3) {
|
|
604
|
+
case 1: {
|
|
605
|
+
yield {
|
|
606
|
+
field: `${prefix}.topic`,
|
|
607
|
+
value: reader.string()
|
|
608
|
+
};
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
case 2: {
|
|
612
|
+
if (opts.limits?.messageIDs != null && obj.messageIDs === opts.limits.messageIDs) {
|
|
613
|
+
throw new MaxLengthError('Streaming decode error - repeated field "messageIDs" had too many elements');
|
|
614
|
+
}
|
|
615
|
+
yield {
|
|
616
|
+
field: `${prefix}.messageIDs[]`,
|
|
617
|
+
index: obj.messageIDs,
|
|
618
|
+
value: reader.bytes()
|
|
619
|
+
};
|
|
620
|
+
obj.messageIDs++;
|
|
621
|
+
break;
|
|
622
|
+
}
|
|
623
|
+
default: {
|
|
624
|
+
reader.skipType(tag & 7);
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
367
629
|
});
|
|
368
630
|
}
|
|
369
631
|
return _codec;
|
|
370
632
|
};
|
|
371
|
-
|
|
633
|
+
function encode(obj) {
|
|
372
634
|
return encodeMessage(obj, ControlIHave.codec());
|
|
373
|
-
}
|
|
374
|
-
ControlIHave.
|
|
635
|
+
}
|
|
636
|
+
ControlIHave.encode = encode;
|
|
637
|
+
function decode(buf, opts) {
|
|
375
638
|
return decodeMessage(buf, ControlIHave.codec(), opts);
|
|
376
|
-
}
|
|
639
|
+
}
|
|
640
|
+
ControlIHave.decode = decode;
|
|
641
|
+
function stream(buf, opts) {
|
|
642
|
+
return streamMessage(buf, ControlIHave.codec(), opts);
|
|
643
|
+
}
|
|
644
|
+
ControlIHave.stream = stream;
|
|
377
645
|
})(ControlIHave || (ControlIHave = {}));
|
|
378
646
|
export var ControlIWant;
|
|
379
647
|
(function (ControlIWant) {
|
|
@@ -384,7 +652,7 @@ export var ControlIWant;
|
|
|
384
652
|
if (opts.lengthDelimited !== false) {
|
|
385
653
|
w.fork();
|
|
386
654
|
}
|
|
387
|
-
if (obj.messageIDs != null) {
|
|
655
|
+
if (obj.messageIDs != null && obj.messageIDs.length > 0) {
|
|
388
656
|
for (const value of obj.messageIDs) {
|
|
389
657
|
w.uint32(10);
|
|
390
658
|
w.bytes(value);
|
|
@@ -403,7 +671,7 @@ export var ControlIWant;
|
|
|
403
671
|
switch (tag >>> 3) {
|
|
404
672
|
case 1: {
|
|
405
673
|
if (opts.limits?.messageIDs != null && obj.messageIDs.length === opts.limits.messageIDs) {
|
|
406
|
-
throw new MaxLengthError('Decode error -
|
|
674
|
+
throw new MaxLengthError('Decode error - repeated field "messageIDs" had too many elements');
|
|
407
675
|
}
|
|
408
676
|
obj.messageIDs.push(reader.bytes());
|
|
409
677
|
break;
|
|
@@ -415,16 +683,48 @@ export var ControlIWant;
|
|
|
415
683
|
}
|
|
416
684
|
}
|
|
417
685
|
return obj;
|
|
686
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
687
|
+
const obj = {
|
|
688
|
+
messageIDs: 0
|
|
689
|
+
};
|
|
690
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
691
|
+
while (reader.pos < end) {
|
|
692
|
+
const tag = reader.uint32();
|
|
693
|
+
switch (tag >>> 3) {
|
|
694
|
+
case 1: {
|
|
695
|
+
if (opts.limits?.messageIDs != null && obj.messageIDs === opts.limits.messageIDs) {
|
|
696
|
+
throw new MaxLengthError('Streaming decode error - repeated field "messageIDs" had too many elements');
|
|
697
|
+
}
|
|
698
|
+
yield {
|
|
699
|
+
field: `${prefix}.messageIDs[]`,
|
|
700
|
+
index: obj.messageIDs,
|
|
701
|
+
value: reader.bytes()
|
|
702
|
+
};
|
|
703
|
+
obj.messageIDs++;
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
default: {
|
|
707
|
+
reader.skipType(tag & 7);
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
418
712
|
});
|
|
419
713
|
}
|
|
420
714
|
return _codec;
|
|
421
715
|
};
|
|
422
|
-
|
|
716
|
+
function encode(obj) {
|
|
423
717
|
return encodeMessage(obj, ControlIWant.codec());
|
|
424
|
-
}
|
|
425
|
-
ControlIWant.
|
|
718
|
+
}
|
|
719
|
+
ControlIWant.encode = encode;
|
|
720
|
+
function decode(buf, opts) {
|
|
426
721
|
return decodeMessage(buf, ControlIWant.codec(), opts);
|
|
427
|
-
}
|
|
722
|
+
}
|
|
723
|
+
ControlIWant.decode = decode;
|
|
724
|
+
function stream(buf, opts) {
|
|
725
|
+
return streamMessage(buf, ControlIWant.codec(), opts);
|
|
726
|
+
}
|
|
727
|
+
ControlIWant.stream = stream;
|
|
428
728
|
})(ControlIWant || (ControlIWant = {}));
|
|
429
729
|
export var ControlGraft;
|
|
430
730
|
(function (ControlGraft) {
|
|
@@ -459,16 +759,40 @@ export var ControlGraft;
|
|
|
459
759
|
}
|
|
460
760
|
}
|
|
461
761
|
return obj;
|
|
762
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
763
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
764
|
+
while (reader.pos < end) {
|
|
765
|
+
const tag = reader.uint32();
|
|
766
|
+
switch (tag >>> 3) {
|
|
767
|
+
case 1: {
|
|
768
|
+
yield {
|
|
769
|
+
field: `${prefix}.topic`,
|
|
770
|
+
value: reader.string()
|
|
771
|
+
};
|
|
772
|
+
break;
|
|
773
|
+
}
|
|
774
|
+
default: {
|
|
775
|
+
reader.skipType(tag & 7);
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
462
780
|
});
|
|
463
781
|
}
|
|
464
782
|
return _codec;
|
|
465
783
|
};
|
|
466
|
-
|
|
784
|
+
function encode(obj) {
|
|
467
785
|
return encodeMessage(obj, ControlGraft.codec());
|
|
468
|
-
}
|
|
469
|
-
ControlGraft.
|
|
786
|
+
}
|
|
787
|
+
ControlGraft.encode = encode;
|
|
788
|
+
function decode(buf, opts) {
|
|
470
789
|
return decodeMessage(buf, ControlGraft.codec(), opts);
|
|
471
|
-
}
|
|
790
|
+
}
|
|
791
|
+
ControlGraft.decode = decode;
|
|
792
|
+
function stream(buf, opts) {
|
|
793
|
+
return streamMessage(buf, ControlGraft.codec(), opts);
|
|
794
|
+
}
|
|
795
|
+
ControlGraft.stream = stream;
|
|
472
796
|
})(ControlGraft || (ControlGraft = {}));
|
|
473
797
|
export var ControlPrune;
|
|
474
798
|
(function (ControlPrune) {
|
|
@@ -483,7 +807,7 @@ export var ControlPrune;
|
|
|
483
807
|
w.uint32(10);
|
|
484
808
|
w.string(obj.topic);
|
|
485
809
|
}
|
|
486
|
-
if (obj.peers != null) {
|
|
810
|
+
if (obj.peers != null && obj.peers.length > 0) {
|
|
487
811
|
for (const value of obj.peers) {
|
|
488
812
|
w.uint32(18);
|
|
489
813
|
PeerInfo.codec().encode(value, w);
|
|
@@ -510,7 +834,7 @@ export var ControlPrune;
|
|
|
510
834
|
}
|
|
511
835
|
case 2: {
|
|
512
836
|
if (opts.limits?.peers != null && obj.peers.length === opts.limits.peers) {
|
|
513
|
-
throw new MaxLengthError('Decode error -
|
|
837
|
+
throw new MaxLengthError('Decode error - repeated field "peers" had too many elements');
|
|
514
838
|
}
|
|
515
839
|
obj.peers.push(PeerInfo.codec().decode(reader, reader.uint32(), {
|
|
516
840
|
limits: opts.limits?.peers$
|
|
@@ -528,16 +852,65 @@ export var ControlPrune;
|
|
|
528
852
|
}
|
|
529
853
|
}
|
|
530
854
|
return obj;
|
|
855
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
856
|
+
const obj = {
|
|
857
|
+
peers: 0
|
|
858
|
+
};
|
|
859
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
860
|
+
while (reader.pos < end) {
|
|
861
|
+
const tag = reader.uint32();
|
|
862
|
+
switch (tag >>> 3) {
|
|
863
|
+
case 1: {
|
|
864
|
+
yield {
|
|
865
|
+
field: `${prefix}.topic`,
|
|
866
|
+
value: reader.string()
|
|
867
|
+
};
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
case 2: {
|
|
871
|
+
if (opts.limits?.peers != null && obj.peers === opts.limits.peers) {
|
|
872
|
+
throw new MaxLengthError('Streaming decode error - repeated field "peers" had too many elements');
|
|
873
|
+
}
|
|
874
|
+
for (const evt of PeerInfo.codec().stream(reader, reader.uint32(), `${prefix}.peers[]`, {
|
|
875
|
+
limits: opts.limits?.peers$
|
|
876
|
+
})) {
|
|
877
|
+
yield {
|
|
878
|
+
...evt,
|
|
879
|
+
index: obj.peers
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
obj.peers++;
|
|
883
|
+
break;
|
|
884
|
+
}
|
|
885
|
+
case 3: {
|
|
886
|
+
yield {
|
|
887
|
+
field: `${prefix}.backoff`,
|
|
888
|
+
value: reader.uint64()
|
|
889
|
+
};
|
|
890
|
+
break;
|
|
891
|
+
}
|
|
892
|
+
default: {
|
|
893
|
+
reader.skipType(tag & 7);
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
531
898
|
});
|
|
532
899
|
}
|
|
533
900
|
return _codec;
|
|
534
901
|
};
|
|
535
|
-
|
|
902
|
+
function encode(obj) {
|
|
536
903
|
return encodeMessage(obj, ControlPrune.codec());
|
|
537
|
-
}
|
|
538
|
-
ControlPrune.
|
|
904
|
+
}
|
|
905
|
+
ControlPrune.encode = encode;
|
|
906
|
+
function decode(buf, opts) {
|
|
539
907
|
return decodeMessage(buf, ControlPrune.codec(), opts);
|
|
540
|
-
}
|
|
908
|
+
}
|
|
909
|
+
ControlPrune.decode = decode;
|
|
910
|
+
function stream(buf, opts) {
|
|
911
|
+
return streamMessage(buf, ControlPrune.codec(), opts);
|
|
912
|
+
}
|
|
913
|
+
ControlPrune.stream = stream;
|
|
541
914
|
})(ControlPrune || (ControlPrune = {}));
|
|
542
915
|
export var PeerInfo;
|
|
543
916
|
(function (PeerInfo) {
|
|
@@ -580,15 +953,46 @@ export var PeerInfo;
|
|
|
580
953
|
}
|
|
581
954
|
}
|
|
582
955
|
return obj;
|
|
956
|
+
}, function* (reader, length, prefix, opts = {}) {
|
|
957
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
958
|
+
while (reader.pos < end) {
|
|
959
|
+
const tag = reader.uint32();
|
|
960
|
+
switch (tag >>> 3) {
|
|
961
|
+
case 1: {
|
|
962
|
+
yield {
|
|
963
|
+
field: `${prefix}.peerID`,
|
|
964
|
+
value: reader.bytes()
|
|
965
|
+
};
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
case 2: {
|
|
969
|
+
yield {
|
|
970
|
+
field: `${prefix}.signedPeerRecord`,
|
|
971
|
+
value: reader.bytes()
|
|
972
|
+
};
|
|
973
|
+
break;
|
|
974
|
+
}
|
|
975
|
+
default: {
|
|
976
|
+
reader.skipType(tag & 7);
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
583
981
|
});
|
|
584
982
|
}
|
|
585
983
|
return _codec;
|
|
586
984
|
};
|
|
587
|
-
|
|
985
|
+
function encode(obj) {
|
|
588
986
|
return encodeMessage(obj, PeerInfo.codec());
|
|
589
|
-
}
|
|
590
|
-
PeerInfo.
|
|
987
|
+
}
|
|
988
|
+
PeerInfo.encode = encode;
|
|
989
|
+
function decode(buf, opts) {
|
|
591
990
|
return decodeMessage(buf, PeerInfo.codec(), opts);
|
|
592
|
-
}
|
|
991
|
+
}
|
|
992
|
+
PeerInfo.decode = decode;
|
|
993
|
+
function stream(buf, opts) {
|
|
994
|
+
return streamMessage(buf, PeerInfo.codec(), opts);
|
|
995
|
+
}
|
|
996
|
+
PeerInfo.stream = stream;
|
|
593
997
|
})(PeerInfo || (PeerInfo = {}));
|
|
594
998
|
//# sourceMappingURL=rpc.js.map
|