@libp2p/floodsub 3.0.3 → 3.0.6
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/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/message/rpc.d.ts +10 -10
- package/dist/src/message/rpc.d.ts.map +1 -1
- package/dist/src/message/rpc.js +444 -43
- package/dist/src/message/rpc.js.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +2 -2
- package/src/message/rpc.ts +532 -53
package/src/message/rpc.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable import/export */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
3
|
|
|
4
|
-
import { encodeMessage, decodeMessage, message
|
|
5
|
-
import type { Codec } from 'protons-runtime'
|
|
4
|
+
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
|
|
6
5
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
6
|
+
import type { Codec } from 'protons-runtime'
|
|
7
7
|
|
|
8
8
|
export interface RPC {
|
|
9
9
|
subscriptions: RPC.SubOpts[]
|
|
@@ -18,14 +18,57 @@ export namespace RPC {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export namespace SubOpts {
|
|
21
|
+
let _codec: Codec<SubOpts>
|
|
22
|
+
|
|
21
23
|
export const codec = (): Codec<SubOpts> => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
if (_codec == null) {
|
|
25
|
+
_codec = message<SubOpts>((obj, writer, opts = {}) => {
|
|
26
|
+
if (opts.lengthDelimited !== false) {
|
|
27
|
+
writer.fork()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (obj.subscribe != null) {
|
|
31
|
+
writer.uint32(8)
|
|
32
|
+
writer.bool(obj.subscribe)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (obj.topic != null) {
|
|
36
|
+
writer.uint32(18)
|
|
37
|
+
writer.string(obj.topic)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (opts.lengthDelimited !== false) {
|
|
41
|
+
writer.ldelim()
|
|
42
|
+
}
|
|
43
|
+
}, (reader, length) => {
|
|
44
|
+
const obj: any = {}
|
|
45
|
+
|
|
46
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
47
|
+
|
|
48
|
+
while (reader.pos < end) {
|
|
49
|
+
const tag = reader.uint32()
|
|
50
|
+
|
|
51
|
+
switch (tag >>> 3) {
|
|
52
|
+
case 1:
|
|
53
|
+
obj.subscribe = reader.bool()
|
|
54
|
+
break
|
|
55
|
+
case 2:
|
|
56
|
+
obj.topic = reader.string()
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
reader.skipType(tag & 7)
|
|
60
|
+
break
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return obj
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return _codec
|
|
26
69
|
}
|
|
27
70
|
|
|
28
|
-
export const encode = (obj: SubOpts):
|
|
71
|
+
export const encode = (obj: SubOpts): Uint8Array => {
|
|
29
72
|
return encodeMessage(obj, SubOpts.codec())
|
|
30
73
|
}
|
|
31
74
|
|
|
@@ -44,18 +87,89 @@ export namespace RPC {
|
|
|
44
87
|
}
|
|
45
88
|
|
|
46
89
|
export namespace Message {
|
|
90
|
+
let _codec: Codec<Message>
|
|
91
|
+
|
|
47
92
|
export const codec = (): Codec<Message> => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
93
|
+
if (_codec == null) {
|
|
94
|
+
_codec = message<Message>((obj, writer, opts = {}) => {
|
|
95
|
+
if (opts.lengthDelimited !== false) {
|
|
96
|
+
writer.fork()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (obj.from != null) {
|
|
100
|
+
writer.uint32(10)
|
|
101
|
+
writer.bytes(obj.from)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (obj.data != null) {
|
|
105
|
+
writer.uint32(18)
|
|
106
|
+
writer.bytes(obj.data)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (obj.sequenceNumber != null) {
|
|
110
|
+
writer.uint32(26)
|
|
111
|
+
writer.bytes(obj.sequenceNumber)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (obj.topic != null) {
|
|
115
|
+
writer.uint32(34)
|
|
116
|
+
writer.string(obj.topic)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (obj.signature != null) {
|
|
120
|
+
writer.uint32(42)
|
|
121
|
+
writer.bytes(obj.signature)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (obj.key != null) {
|
|
125
|
+
writer.uint32(50)
|
|
126
|
+
writer.bytes(obj.key)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (opts.lengthDelimited !== false) {
|
|
130
|
+
writer.ldelim()
|
|
131
|
+
}
|
|
132
|
+
}, (reader, length) => {
|
|
133
|
+
const obj: any = {}
|
|
134
|
+
|
|
135
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
136
|
+
|
|
137
|
+
while (reader.pos < end) {
|
|
138
|
+
const tag = reader.uint32()
|
|
139
|
+
|
|
140
|
+
switch (tag >>> 3) {
|
|
141
|
+
case 1:
|
|
142
|
+
obj.from = reader.bytes()
|
|
143
|
+
break
|
|
144
|
+
case 2:
|
|
145
|
+
obj.data = reader.bytes()
|
|
146
|
+
break
|
|
147
|
+
case 3:
|
|
148
|
+
obj.sequenceNumber = reader.bytes()
|
|
149
|
+
break
|
|
150
|
+
case 4:
|
|
151
|
+
obj.topic = reader.string()
|
|
152
|
+
break
|
|
153
|
+
case 5:
|
|
154
|
+
obj.signature = reader.bytes()
|
|
155
|
+
break
|
|
156
|
+
case 6:
|
|
157
|
+
obj.key = reader.bytes()
|
|
158
|
+
break
|
|
159
|
+
default:
|
|
160
|
+
reader.skipType(tag & 7)
|
|
161
|
+
break
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return obj
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return _codec
|
|
56
170
|
}
|
|
57
171
|
|
|
58
|
-
export const encode = (obj: Message):
|
|
172
|
+
export const encode = (obj: Message): Uint8Array => {
|
|
59
173
|
return encodeMessage(obj, Message.codec())
|
|
60
174
|
}
|
|
61
175
|
|
|
@@ -64,15 +178,76 @@ export namespace RPC {
|
|
|
64
178
|
}
|
|
65
179
|
}
|
|
66
180
|
|
|
181
|
+
let _codec: Codec<RPC>
|
|
182
|
+
|
|
67
183
|
export const codec = (): Codec<RPC> => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
184
|
+
if (_codec == null) {
|
|
185
|
+
_codec = message<RPC>((obj, writer, opts = {}) => {
|
|
186
|
+
if (opts.lengthDelimited !== false) {
|
|
187
|
+
writer.fork()
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (obj.subscriptions != null) {
|
|
191
|
+
for (const value of obj.subscriptions) {
|
|
192
|
+
writer.uint32(10)
|
|
193
|
+
RPC.SubOpts.codec().encode(value, writer)
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
throw new Error('Protocol error: required field "subscriptions" was not found in object')
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (obj.messages != null) {
|
|
200
|
+
for (const value of obj.messages) {
|
|
201
|
+
writer.uint32(18)
|
|
202
|
+
RPC.Message.codec().encode(value, writer)
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
throw new Error('Protocol error: required field "messages" was not found in object')
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (obj.control != null) {
|
|
209
|
+
writer.uint32(26)
|
|
210
|
+
ControlMessage.codec().encode(obj.control, writer)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (opts.lengthDelimited !== false) {
|
|
214
|
+
writer.ldelim()
|
|
215
|
+
}
|
|
216
|
+
}, (reader, length) => {
|
|
217
|
+
const obj: any = {
|
|
218
|
+
subscriptions: [],
|
|
219
|
+
messages: []
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
223
|
+
|
|
224
|
+
while (reader.pos < end) {
|
|
225
|
+
const tag = reader.uint32()
|
|
226
|
+
|
|
227
|
+
switch (tag >>> 3) {
|
|
228
|
+
case 1:
|
|
229
|
+
obj.subscriptions.push(RPC.SubOpts.codec().decode(reader, reader.uint32()))
|
|
230
|
+
break
|
|
231
|
+
case 2:
|
|
232
|
+
obj.messages.push(RPC.Message.codec().decode(reader, reader.uint32()))
|
|
233
|
+
break
|
|
234
|
+
case 3:
|
|
235
|
+
obj.control = ControlMessage.codec().decode(reader, reader.uint32())
|
|
236
|
+
break
|
|
237
|
+
default:
|
|
238
|
+
reader.skipType(tag & 7)
|
|
239
|
+
break
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return obj
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return _codec
|
|
73
248
|
}
|
|
74
249
|
|
|
75
|
-
export const encode = (obj: RPC):
|
|
250
|
+
export const encode = (obj: RPC): Uint8Array => {
|
|
76
251
|
return encodeMessage(obj, RPC.codec())
|
|
77
252
|
}
|
|
78
253
|
|
|
@@ -89,16 +264,94 @@ export interface ControlMessage {
|
|
|
89
264
|
}
|
|
90
265
|
|
|
91
266
|
export namespace ControlMessage {
|
|
267
|
+
let _codec: Codec<ControlMessage>
|
|
268
|
+
|
|
92
269
|
export const codec = (): Codec<ControlMessage> => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
270
|
+
if (_codec == null) {
|
|
271
|
+
_codec = message<ControlMessage>((obj, writer, opts = {}) => {
|
|
272
|
+
if (opts.lengthDelimited !== false) {
|
|
273
|
+
writer.fork()
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (obj.ihave != null) {
|
|
277
|
+
for (const value of obj.ihave) {
|
|
278
|
+
writer.uint32(10)
|
|
279
|
+
ControlIHave.codec().encode(value, writer)
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
throw new Error('Protocol error: required field "ihave" was not found in object')
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (obj.iwant != null) {
|
|
286
|
+
for (const value of obj.iwant) {
|
|
287
|
+
writer.uint32(18)
|
|
288
|
+
ControlIWant.codec().encode(value, writer)
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
throw new Error('Protocol error: required field "iwant" was not found in object')
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (obj.graft != null) {
|
|
295
|
+
for (const value of obj.graft) {
|
|
296
|
+
writer.uint32(26)
|
|
297
|
+
ControlGraft.codec().encode(value, writer)
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
throw new Error('Protocol error: required field "graft" was not found in object')
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (obj.prune != null) {
|
|
304
|
+
for (const value of obj.prune) {
|
|
305
|
+
writer.uint32(34)
|
|
306
|
+
ControlPrune.codec().encode(value, writer)
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
throw new Error('Protocol error: required field "prune" was not found in object')
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (opts.lengthDelimited !== false) {
|
|
313
|
+
writer.ldelim()
|
|
314
|
+
}
|
|
315
|
+
}, (reader, length) => {
|
|
316
|
+
const obj: any = {
|
|
317
|
+
ihave: [],
|
|
318
|
+
iwant: [],
|
|
319
|
+
graft: [],
|
|
320
|
+
prune: []
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
324
|
+
|
|
325
|
+
while (reader.pos < end) {
|
|
326
|
+
const tag = reader.uint32()
|
|
327
|
+
|
|
328
|
+
switch (tag >>> 3) {
|
|
329
|
+
case 1:
|
|
330
|
+
obj.ihave.push(ControlIHave.codec().decode(reader, reader.uint32()))
|
|
331
|
+
break
|
|
332
|
+
case 2:
|
|
333
|
+
obj.iwant.push(ControlIWant.codec().decode(reader, reader.uint32()))
|
|
334
|
+
break
|
|
335
|
+
case 3:
|
|
336
|
+
obj.graft.push(ControlGraft.codec().decode(reader, reader.uint32()))
|
|
337
|
+
break
|
|
338
|
+
case 4:
|
|
339
|
+
obj.prune.push(ControlPrune.codec().decode(reader, reader.uint32()))
|
|
340
|
+
break
|
|
341
|
+
default:
|
|
342
|
+
reader.skipType(tag & 7)
|
|
343
|
+
break
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return obj
|
|
348
|
+
})
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return _codec
|
|
99
352
|
}
|
|
100
353
|
|
|
101
|
-
export const encode = (obj: ControlMessage):
|
|
354
|
+
export const encode = (obj: ControlMessage): Uint8Array => {
|
|
102
355
|
return encodeMessage(obj, ControlMessage.codec())
|
|
103
356
|
}
|
|
104
357
|
|
|
@@ -113,14 +366,63 @@ export interface ControlIHave {
|
|
|
113
366
|
}
|
|
114
367
|
|
|
115
368
|
export namespace ControlIHave {
|
|
369
|
+
let _codec: Codec<ControlIHave>
|
|
370
|
+
|
|
116
371
|
export const codec = (): Codec<ControlIHave> => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
372
|
+
if (_codec == null) {
|
|
373
|
+
_codec = message<ControlIHave>((obj, writer, opts = {}) => {
|
|
374
|
+
if (opts.lengthDelimited !== false) {
|
|
375
|
+
writer.fork()
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (obj.topic != null) {
|
|
379
|
+
writer.uint32(10)
|
|
380
|
+
writer.string(obj.topic)
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (obj.messageIDs != null) {
|
|
384
|
+
for (const value of obj.messageIDs) {
|
|
385
|
+
writer.uint32(18)
|
|
386
|
+
writer.bytes(value)
|
|
387
|
+
}
|
|
388
|
+
} else {
|
|
389
|
+
throw new Error('Protocol error: required field "messageIDs" was not found in object')
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (opts.lengthDelimited !== false) {
|
|
393
|
+
writer.ldelim()
|
|
394
|
+
}
|
|
395
|
+
}, (reader, length) => {
|
|
396
|
+
const obj: any = {
|
|
397
|
+
messageIDs: []
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
401
|
+
|
|
402
|
+
while (reader.pos < end) {
|
|
403
|
+
const tag = reader.uint32()
|
|
404
|
+
|
|
405
|
+
switch (tag >>> 3) {
|
|
406
|
+
case 1:
|
|
407
|
+
obj.topic = reader.string()
|
|
408
|
+
break
|
|
409
|
+
case 2:
|
|
410
|
+
obj.messageIDs.push(reader.bytes())
|
|
411
|
+
break
|
|
412
|
+
default:
|
|
413
|
+
reader.skipType(tag & 7)
|
|
414
|
+
break
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return obj
|
|
419
|
+
})
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return _codec
|
|
121
423
|
}
|
|
122
424
|
|
|
123
|
-
export const encode = (obj: ControlIHave):
|
|
425
|
+
export const encode = (obj: ControlIHave): Uint8Array => {
|
|
124
426
|
return encodeMessage(obj, ControlIHave.codec())
|
|
125
427
|
}
|
|
126
428
|
|
|
@@ -134,13 +436,55 @@ export interface ControlIWant {
|
|
|
134
436
|
}
|
|
135
437
|
|
|
136
438
|
export namespace ControlIWant {
|
|
439
|
+
let _codec: Codec<ControlIWant>
|
|
440
|
+
|
|
137
441
|
export const codec = (): Codec<ControlIWant> => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
442
|
+
if (_codec == null) {
|
|
443
|
+
_codec = message<ControlIWant>((obj, writer, opts = {}) => {
|
|
444
|
+
if (opts.lengthDelimited !== false) {
|
|
445
|
+
writer.fork()
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (obj.messageIDs != null) {
|
|
449
|
+
for (const value of obj.messageIDs) {
|
|
450
|
+
writer.uint32(10)
|
|
451
|
+
writer.bytes(value)
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
throw new Error('Protocol error: required field "messageIDs" was not found in object')
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (opts.lengthDelimited !== false) {
|
|
458
|
+
writer.ldelim()
|
|
459
|
+
}
|
|
460
|
+
}, (reader, length) => {
|
|
461
|
+
const obj: any = {
|
|
462
|
+
messageIDs: []
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
466
|
+
|
|
467
|
+
while (reader.pos < end) {
|
|
468
|
+
const tag = reader.uint32()
|
|
469
|
+
|
|
470
|
+
switch (tag >>> 3) {
|
|
471
|
+
case 1:
|
|
472
|
+
obj.messageIDs.push(reader.bytes())
|
|
473
|
+
break
|
|
474
|
+
default:
|
|
475
|
+
reader.skipType(tag & 7)
|
|
476
|
+
break
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return obj
|
|
481
|
+
})
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return _codec
|
|
141
485
|
}
|
|
142
486
|
|
|
143
|
-
export const encode = (obj: ControlIWant):
|
|
487
|
+
export const encode = (obj: ControlIWant): Uint8Array => {
|
|
144
488
|
return encodeMessage(obj, ControlIWant.codec())
|
|
145
489
|
}
|
|
146
490
|
|
|
@@ -154,13 +498,49 @@ export interface ControlGraft {
|
|
|
154
498
|
}
|
|
155
499
|
|
|
156
500
|
export namespace ControlGraft {
|
|
501
|
+
let _codec: Codec<ControlGraft>
|
|
502
|
+
|
|
157
503
|
export const codec = (): Codec<ControlGraft> => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
504
|
+
if (_codec == null) {
|
|
505
|
+
_codec = message<ControlGraft>((obj, writer, opts = {}) => {
|
|
506
|
+
if (opts.lengthDelimited !== false) {
|
|
507
|
+
writer.fork()
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
if (obj.topic != null) {
|
|
511
|
+
writer.uint32(10)
|
|
512
|
+
writer.string(obj.topic)
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (opts.lengthDelimited !== false) {
|
|
516
|
+
writer.ldelim()
|
|
517
|
+
}
|
|
518
|
+
}, (reader, length) => {
|
|
519
|
+
const obj: any = {}
|
|
520
|
+
|
|
521
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
522
|
+
|
|
523
|
+
while (reader.pos < end) {
|
|
524
|
+
const tag = reader.uint32()
|
|
525
|
+
|
|
526
|
+
switch (tag >>> 3) {
|
|
527
|
+
case 1:
|
|
528
|
+
obj.topic = reader.string()
|
|
529
|
+
break
|
|
530
|
+
default:
|
|
531
|
+
reader.skipType(tag & 7)
|
|
532
|
+
break
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
return obj
|
|
537
|
+
})
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return _codec
|
|
161
541
|
}
|
|
162
542
|
|
|
163
|
-
export const encode = (obj: ControlGraft):
|
|
543
|
+
export const encode = (obj: ControlGraft): Uint8Array => {
|
|
164
544
|
return encodeMessage(obj, ControlGraft.codec())
|
|
165
545
|
}
|
|
166
546
|
|
|
@@ -176,15 +556,71 @@ export interface ControlPrune {
|
|
|
176
556
|
}
|
|
177
557
|
|
|
178
558
|
export namespace ControlPrune {
|
|
559
|
+
let _codec: Codec<ControlPrune>
|
|
560
|
+
|
|
179
561
|
export const codec = (): Codec<ControlPrune> => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
562
|
+
if (_codec == null) {
|
|
563
|
+
_codec = message<ControlPrune>((obj, writer, opts = {}) => {
|
|
564
|
+
if (opts.lengthDelimited !== false) {
|
|
565
|
+
writer.fork()
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (obj.topic != null) {
|
|
569
|
+
writer.uint32(10)
|
|
570
|
+
writer.string(obj.topic)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
if (obj.peers != null) {
|
|
574
|
+
for (const value of obj.peers) {
|
|
575
|
+
writer.uint32(18)
|
|
576
|
+
PeerInfo.codec().encode(value, writer)
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
throw new Error('Protocol error: required field "peers" was not found in object')
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
if (obj.backoff != null) {
|
|
583
|
+
writer.uint32(24)
|
|
584
|
+
writer.uint64(obj.backoff)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (opts.lengthDelimited !== false) {
|
|
588
|
+
writer.ldelim()
|
|
589
|
+
}
|
|
590
|
+
}, (reader, length) => {
|
|
591
|
+
const obj: any = {
|
|
592
|
+
peers: []
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
596
|
+
|
|
597
|
+
while (reader.pos < end) {
|
|
598
|
+
const tag = reader.uint32()
|
|
599
|
+
|
|
600
|
+
switch (tag >>> 3) {
|
|
601
|
+
case 1:
|
|
602
|
+
obj.topic = reader.string()
|
|
603
|
+
break
|
|
604
|
+
case 2:
|
|
605
|
+
obj.peers.push(PeerInfo.codec().decode(reader, reader.uint32()))
|
|
606
|
+
break
|
|
607
|
+
case 3:
|
|
608
|
+
obj.backoff = reader.uint64()
|
|
609
|
+
break
|
|
610
|
+
default:
|
|
611
|
+
reader.skipType(tag & 7)
|
|
612
|
+
break
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
return obj
|
|
617
|
+
})
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return _codec
|
|
185
621
|
}
|
|
186
622
|
|
|
187
|
-
export const encode = (obj: ControlPrune):
|
|
623
|
+
export const encode = (obj: ControlPrune): Uint8Array => {
|
|
188
624
|
return encodeMessage(obj, ControlPrune.codec())
|
|
189
625
|
}
|
|
190
626
|
|
|
@@ -199,14 +635,57 @@ export interface PeerInfo {
|
|
|
199
635
|
}
|
|
200
636
|
|
|
201
637
|
export namespace PeerInfo {
|
|
638
|
+
let _codec: Codec<PeerInfo>
|
|
639
|
+
|
|
202
640
|
export const codec = (): Codec<PeerInfo> => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
641
|
+
if (_codec == null) {
|
|
642
|
+
_codec = message<PeerInfo>((obj, writer, opts = {}) => {
|
|
643
|
+
if (opts.lengthDelimited !== false) {
|
|
644
|
+
writer.fork()
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (obj.peerID != null) {
|
|
648
|
+
writer.uint32(10)
|
|
649
|
+
writer.bytes(obj.peerID)
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (obj.signedPeerRecord != null) {
|
|
653
|
+
writer.uint32(18)
|
|
654
|
+
writer.bytes(obj.signedPeerRecord)
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
if (opts.lengthDelimited !== false) {
|
|
658
|
+
writer.ldelim()
|
|
659
|
+
}
|
|
660
|
+
}, (reader, length) => {
|
|
661
|
+
const obj: any = {}
|
|
662
|
+
|
|
663
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
664
|
+
|
|
665
|
+
while (reader.pos < end) {
|
|
666
|
+
const tag = reader.uint32()
|
|
667
|
+
|
|
668
|
+
switch (tag >>> 3) {
|
|
669
|
+
case 1:
|
|
670
|
+
obj.peerID = reader.bytes()
|
|
671
|
+
break
|
|
672
|
+
case 2:
|
|
673
|
+
obj.signedPeerRecord = reader.bytes()
|
|
674
|
+
break
|
|
675
|
+
default:
|
|
676
|
+
reader.skipType(tag & 7)
|
|
677
|
+
break
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
return obj
|
|
682
|
+
})
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return _codec
|
|
207
686
|
}
|
|
208
687
|
|
|
209
|
-
export const encode = (obj: PeerInfo):
|
|
688
|
+
export const encode = (obj: PeerInfo): Uint8Array => {
|
|
210
689
|
return encodeMessage(obj, PeerInfo.codec())
|
|
211
690
|
}
|
|
212
691
|
|