@libp2p/floodsub 3.0.3 → 3.0.4
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 +475 -43
- package/dist/src/message/rpc.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +2 -2
- package/src/message/rpc.ts +577 -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,86 @@ 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
|
+
|
|
219
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
220
|
+
|
|
221
|
+
while (reader.pos < end) {
|
|
222
|
+
const tag = reader.uint32()
|
|
223
|
+
|
|
224
|
+
switch (tag >>> 3) {
|
|
225
|
+
case 1:
|
|
226
|
+
obj.subscriptions = obj.subscriptions ?? []
|
|
227
|
+
obj.subscriptions.push(RPC.SubOpts.codec().decode(reader, reader.uint32()))
|
|
228
|
+
break
|
|
229
|
+
case 2:
|
|
230
|
+
obj.messages = obj.messages ?? []
|
|
231
|
+
obj.messages.push(RPC.Message.codec().decode(reader, reader.uint32()))
|
|
232
|
+
break
|
|
233
|
+
case 3:
|
|
234
|
+
obj.control = ControlMessage.codec().decode(reader, reader.uint32())
|
|
235
|
+
break
|
|
236
|
+
default:
|
|
237
|
+
reader.skipType(tag & 7)
|
|
238
|
+
break
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
obj.subscriptions = obj.subscriptions ?? []
|
|
243
|
+
obj.messages = obj.messages ?? []
|
|
244
|
+
|
|
245
|
+
if (obj.subscriptions == null) {
|
|
246
|
+
throw new Error('Protocol error: value for required field "subscriptions" was not found in protobuf')
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (obj.messages == null) {
|
|
250
|
+
throw new Error('Protocol error: value for required field "messages" was not found in protobuf')
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return obj
|
|
254
|
+
})
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return _codec
|
|
73
258
|
}
|
|
74
259
|
|
|
75
|
-
export const encode = (obj: RPC):
|
|
260
|
+
export const encode = (obj: RPC): Uint8Array => {
|
|
76
261
|
return encodeMessage(obj, RPC.codec())
|
|
77
262
|
}
|
|
78
263
|
|
|
@@ -89,16 +274,114 @@ export interface ControlMessage {
|
|
|
89
274
|
}
|
|
90
275
|
|
|
91
276
|
export namespace ControlMessage {
|
|
277
|
+
let _codec: Codec<ControlMessage>
|
|
278
|
+
|
|
92
279
|
export const codec = (): Codec<ControlMessage> => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
280
|
+
if (_codec == null) {
|
|
281
|
+
_codec = message<ControlMessage>((obj, writer, opts = {}) => {
|
|
282
|
+
if (opts.lengthDelimited !== false) {
|
|
283
|
+
writer.fork()
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (obj.ihave != null) {
|
|
287
|
+
for (const value of obj.ihave) {
|
|
288
|
+
writer.uint32(10)
|
|
289
|
+
ControlIHave.codec().encode(value, writer)
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
throw new Error('Protocol error: required field "ihave" was not found in object')
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (obj.iwant != null) {
|
|
296
|
+
for (const value of obj.iwant) {
|
|
297
|
+
writer.uint32(18)
|
|
298
|
+
ControlIWant.codec().encode(value, writer)
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
throw new Error('Protocol error: required field "iwant" was not found in object')
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (obj.graft != null) {
|
|
305
|
+
for (const value of obj.graft) {
|
|
306
|
+
writer.uint32(26)
|
|
307
|
+
ControlGraft.codec().encode(value, writer)
|
|
308
|
+
}
|
|
309
|
+
} else {
|
|
310
|
+
throw new Error('Protocol error: required field "graft" was not found in object')
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (obj.prune != null) {
|
|
314
|
+
for (const value of obj.prune) {
|
|
315
|
+
writer.uint32(34)
|
|
316
|
+
ControlPrune.codec().encode(value, writer)
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
throw new Error('Protocol error: required field "prune" was not found in object')
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (opts.lengthDelimited !== false) {
|
|
323
|
+
writer.ldelim()
|
|
324
|
+
}
|
|
325
|
+
}, (reader, length) => {
|
|
326
|
+
const obj: any = {}
|
|
327
|
+
|
|
328
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
329
|
+
|
|
330
|
+
while (reader.pos < end) {
|
|
331
|
+
const tag = reader.uint32()
|
|
332
|
+
|
|
333
|
+
switch (tag >>> 3) {
|
|
334
|
+
case 1:
|
|
335
|
+
obj.ihave = obj.ihave ?? []
|
|
336
|
+
obj.ihave.push(ControlIHave.codec().decode(reader, reader.uint32()))
|
|
337
|
+
break
|
|
338
|
+
case 2:
|
|
339
|
+
obj.iwant = obj.iwant ?? []
|
|
340
|
+
obj.iwant.push(ControlIWant.codec().decode(reader, reader.uint32()))
|
|
341
|
+
break
|
|
342
|
+
case 3:
|
|
343
|
+
obj.graft = obj.graft ?? []
|
|
344
|
+
obj.graft.push(ControlGraft.codec().decode(reader, reader.uint32()))
|
|
345
|
+
break
|
|
346
|
+
case 4:
|
|
347
|
+
obj.prune = obj.prune ?? []
|
|
348
|
+
obj.prune.push(ControlPrune.codec().decode(reader, reader.uint32()))
|
|
349
|
+
break
|
|
350
|
+
default:
|
|
351
|
+
reader.skipType(tag & 7)
|
|
352
|
+
break
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
obj.ihave = obj.ihave ?? []
|
|
357
|
+
obj.iwant = obj.iwant ?? []
|
|
358
|
+
obj.graft = obj.graft ?? []
|
|
359
|
+
obj.prune = obj.prune ?? []
|
|
360
|
+
|
|
361
|
+
if (obj.ihave == null) {
|
|
362
|
+
throw new Error('Protocol error: value for required field "ihave" was not found in protobuf')
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (obj.iwant == null) {
|
|
366
|
+
throw new Error('Protocol error: value for required field "iwant" was not found in protobuf')
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (obj.graft == null) {
|
|
370
|
+
throw new Error('Protocol error: value for required field "graft" was not found in protobuf')
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (obj.prune == null) {
|
|
374
|
+
throw new Error('Protocol error: value for required field "prune" was not found in protobuf')
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return obj
|
|
378
|
+
})
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return _codec
|
|
99
382
|
}
|
|
100
383
|
|
|
101
|
-
export const encode = (obj: ControlMessage):
|
|
384
|
+
export const encode = (obj: ControlMessage): Uint8Array => {
|
|
102
385
|
return encodeMessage(obj, ControlMessage.codec())
|
|
103
386
|
}
|
|
104
387
|
|
|
@@ -113,14 +396,68 @@ export interface ControlIHave {
|
|
|
113
396
|
}
|
|
114
397
|
|
|
115
398
|
export namespace ControlIHave {
|
|
399
|
+
let _codec: Codec<ControlIHave>
|
|
400
|
+
|
|
116
401
|
export const codec = (): Codec<ControlIHave> => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
402
|
+
if (_codec == null) {
|
|
403
|
+
_codec = message<ControlIHave>((obj, writer, opts = {}) => {
|
|
404
|
+
if (opts.lengthDelimited !== false) {
|
|
405
|
+
writer.fork()
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (obj.topic != null) {
|
|
409
|
+
writer.uint32(10)
|
|
410
|
+
writer.string(obj.topic)
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (obj.messageIDs != null) {
|
|
414
|
+
for (const value of obj.messageIDs) {
|
|
415
|
+
writer.uint32(18)
|
|
416
|
+
writer.bytes(value)
|
|
417
|
+
}
|
|
418
|
+
} else {
|
|
419
|
+
throw new Error('Protocol error: required field "messageIDs" was not found in object')
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (opts.lengthDelimited !== false) {
|
|
423
|
+
writer.ldelim()
|
|
424
|
+
}
|
|
425
|
+
}, (reader, length) => {
|
|
426
|
+
const obj: any = {}
|
|
427
|
+
|
|
428
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
429
|
+
|
|
430
|
+
while (reader.pos < end) {
|
|
431
|
+
const tag = reader.uint32()
|
|
432
|
+
|
|
433
|
+
switch (tag >>> 3) {
|
|
434
|
+
case 1:
|
|
435
|
+
obj.topic = reader.string()
|
|
436
|
+
break
|
|
437
|
+
case 2:
|
|
438
|
+
obj.messageIDs = obj.messageIDs ?? []
|
|
439
|
+
obj.messageIDs.push(reader.bytes())
|
|
440
|
+
break
|
|
441
|
+
default:
|
|
442
|
+
reader.skipType(tag & 7)
|
|
443
|
+
break
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
obj.messageIDs = obj.messageIDs ?? []
|
|
448
|
+
|
|
449
|
+
if (obj.messageIDs == null) {
|
|
450
|
+
throw new Error('Protocol error: value for required field "messageIDs" was not found in protobuf')
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return obj
|
|
454
|
+
})
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return _codec
|
|
121
458
|
}
|
|
122
459
|
|
|
123
|
-
export const encode = (obj: ControlIHave):
|
|
460
|
+
export const encode = (obj: ControlIHave): Uint8Array => {
|
|
124
461
|
return encodeMessage(obj, ControlIHave.codec())
|
|
125
462
|
}
|
|
126
463
|
|
|
@@ -134,13 +471,60 @@ export interface ControlIWant {
|
|
|
134
471
|
}
|
|
135
472
|
|
|
136
473
|
export namespace ControlIWant {
|
|
474
|
+
let _codec: Codec<ControlIWant>
|
|
475
|
+
|
|
137
476
|
export const codec = (): Codec<ControlIWant> => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
477
|
+
if (_codec == null) {
|
|
478
|
+
_codec = message<ControlIWant>((obj, writer, opts = {}) => {
|
|
479
|
+
if (opts.lengthDelimited !== false) {
|
|
480
|
+
writer.fork()
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
if (obj.messageIDs != null) {
|
|
484
|
+
for (const value of obj.messageIDs) {
|
|
485
|
+
writer.uint32(10)
|
|
486
|
+
writer.bytes(value)
|
|
487
|
+
}
|
|
488
|
+
} else {
|
|
489
|
+
throw new Error('Protocol error: required field "messageIDs" was not found in object')
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (opts.lengthDelimited !== false) {
|
|
493
|
+
writer.ldelim()
|
|
494
|
+
}
|
|
495
|
+
}, (reader, length) => {
|
|
496
|
+
const obj: any = {}
|
|
497
|
+
|
|
498
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
499
|
+
|
|
500
|
+
while (reader.pos < end) {
|
|
501
|
+
const tag = reader.uint32()
|
|
502
|
+
|
|
503
|
+
switch (tag >>> 3) {
|
|
504
|
+
case 1:
|
|
505
|
+
obj.messageIDs = obj.messageIDs ?? []
|
|
506
|
+
obj.messageIDs.push(reader.bytes())
|
|
507
|
+
break
|
|
508
|
+
default:
|
|
509
|
+
reader.skipType(tag & 7)
|
|
510
|
+
break
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
obj.messageIDs = obj.messageIDs ?? []
|
|
515
|
+
|
|
516
|
+
if (obj.messageIDs == null) {
|
|
517
|
+
throw new Error('Protocol error: value for required field "messageIDs" was not found in protobuf')
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
return obj
|
|
521
|
+
})
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return _codec
|
|
141
525
|
}
|
|
142
526
|
|
|
143
|
-
export const encode = (obj: ControlIWant):
|
|
527
|
+
export const encode = (obj: ControlIWant): Uint8Array => {
|
|
144
528
|
return encodeMessage(obj, ControlIWant.codec())
|
|
145
529
|
}
|
|
146
530
|
|
|
@@ -154,13 +538,49 @@ export interface ControlGraft {
|
|
|
154
538
|
}
|
|
155
539
|
|
|
156
540
|
export namespace ControlGraft {
|
|
541
|
+
let _codec: Codec<ControlGraft>
|
|
542
|
+
|
|
157
543
|
export const codec = (): Codec<ControlGraft> => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
544
|
+
if (_codec == null) {
|
|
545
|
+
_codec = message<ControlGraft>((obj, writer, opts = {}) => {
|
|
546
|
+
if (opts.lengthDelimited !== false) {
|
|
547
|
+
writer.fork()
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (obj.topic != null) {
|
|
551
|
+
writer.uint32(10)
|
|
552
|
+
writer.string(obj.topic)
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (opts.lengthDelimited !== false) {
|
|
556
|
+
writer.ldelim()
|
|
557
|
+
}
|
|
558
|
+
}, (reader, length) => {
|
|
559
|
+
const obj: any = {}
|
|
560
|
+
|
|
561
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
562
|
+
|
|
563
|
+
while (reader.pos < end) {
|
|
564
|
+
const tag = reader.uint32()
|
|
565
|
+
|
|
566
|
+
switch (tag >>> 3) {
|
|
567
|
+
case 1:
|
|
568
|
+
obj.topic = reader.string()
|
|
569
|
+
break
|
|
570
|
+
default:
|
|
571
|
+
reader.skipType(tag & 7)
|
|
572
|
+
break
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return obj
|
|
577
|
+
})
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
return _codec
|
|
161
581
|
}
|
|
162
582
|
|
|
163
|
-
export const encode = (obj: ControlGraft):
|
|
583
|
+
export const encode = (obj: ControlGraft): Uint8Array => {
|
|
164
584
|
return encodeMessage(obj, ControlGraft.codec())
|
|
165
585
|
}
|
|
166
586
|
|
|
@@ -176,15 +596,76 @@ export interface ControlPrune {
|
|
|
176
596
|
}
|
|
177
597
|
|
|
178
598
|
export namespace ControlPrune {
|
|
599
|
+
let _codec: Codec<ControlPrune>
|
|
600
|
+
|
|
179
601
|
export const codec = (): Codec<ControlPrune> => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
602
|
+
if (_codec == null) {
|
|
603
|
+
_codec = message<ControlPrune>((obj, writer, opts = {}) => {
|
|
604
|
+
if (opts.lengthDelimited !== false) {
|
|
605
|
+
writer.fork()
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
if (obj.topic != null) {
|
|
609
|
+
writer.uint32(10)
|
|
610
|
+
writer.string(obj.topic)
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
if (obj.peers != null) {
|
|
614
|
+
for (const value of obj.peers) {
|
|
615
|
+
writer.uint32(18)
|
|
616
|
+
PeerInfo.codec().encode(value, writer)
|
|
617
|
+
}
|
|
618
|
+
} else {
|
|
619
|
+
throw new Error('Protocol error: required field "peers" was not found in object')
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (obj.backoff != null) {
|
|
623
|
+
writer.uint32(24)
|
|
624
|
+
writer.uint64(obj.backoff)
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if (opts.lengthDelimited !== false) {
|
|
628
|
+
writer.ldelim()
|
|
629
|
+
}
|
|
630
|
+
}, (reader, length) => {
|
|
631
|
+
const obj: any = {}
|
|
632
|
+
|
|
633
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
634
|
+
|
|
635
|
+
while (reader.pos < end) {
|
|
636
|
+
const tag = reader.uint32()
|
|
637
|
+
|
|
638
|
+
switch (tag >>> 3) {
|
|
639
|
+
case 1:
|
|
640
|
+
obj.topic = reader.string()
|
|
641
|
+
break
|
|
642
|
+
case 2:
|
|
643
|
+
obj.peers = obj.peers ?? []
|
|
644
|
+
obj.peers.push(PeerInfo.codec().decode(reader, reader.uint32()))
|
|
645
|
+
break
|
|
646
|
+
case 3:
|
|
647
|
+
obj.backoff = reader.uint64()
|
|
648
|
+
break
|
|
649
|
+
default:
|
|
650
|
+
reader.skipType(tag & 7)
|
|
651
|
+
break
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
obj.peers = obj.peers ?? []
|
|
656
|
+
|
|
657
|
+
if (obj.peers == null) {
|
|
658
|
+
throw new Error('Protocol error: value for required field "peers" was not found in protobuf')
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
return obj
|
|
662
|
+
})
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
return _codec
|
|
185
666
|
}
|
|
186
667
|
|
|
187
|
-
export const encode = (obj: ControlPrune):
|
|
668
|
+
export const encode = (obj: ControlPrune): Uint8Array => {
|
|
188
669
|
return encodeMessage(obj, ControlPrune.codec())
|
|
189
670
|
}
|
|
190
671
|
|
|
@@ -199,14 +680,57 @@ export interface PeerInfo {
|
|
|
199
680
|
}
|
|
200
681
|
|
|
201
682
|
export namespace PeerInfo {
|
|
683
|
+
let _codec: Codec<PeerInfo>
|
|
684
|
+
|
|
202
685
|
export const codec = (): Codec<PeerInfo> => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
686
|
+
if (_codec == null) {
|
|
687
|
+
_codec = message<PeerInfo>((obj, writer, opts = {}) => {
|
|
688
|
+
if (opts.lengthDelimited !== false) {
|
|
689
|
+
writer.fork()
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if (obj.peerID != null) {
|
|
693
|
+
writer.uint32(10)
|
|
694
|
+
writer.bytes(obj.peerID)
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (obj.signedPeerRecord != null) {
|
|
698
|
+
writer.uint32(18)
|
|
699
|
+
writer.bytes(obj.signedPeerRecord)
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (opts.lengthDelimited !== false) {
|
|
703
|
+
writer.ldelim()
|
|
704
|
+
}
|
|
705
|
+
}, (reader, length) => {
|
|
706
|
+
const obj: any = {}
|
|
707
|
+
|
|
708
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
709
|
+
|
|
710
|
+
while (reader.pos < end) {
|
|
711
|
+
const tag = reader.uint32()
|
|
712
|
+
|
|
713
|
+
switch (tag >>> 3) {
|
|
714
|
+
case 1:
|
|
715
|
+
obj.peerID = reader.bytes()
|
|
716
|
+
break
|
|
717
|
+
case 2:
|
|
718
|
+
obj.signedPeerRecord = reader.bytes()
|
|
719
|
+
break
|
|
720
|
+
default:
|
|
721
|
+
reader.skipType(tag & 7)
|
|
722
|
+
break
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
return obj
|
|
727
|
+
})
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
return _codec
|
|
207
731
|
}
|
|
208
732
|
|
|
209
|
-
export const encode = (obj: PeerInfo):
|
|
733
|
+
export const encode = (obj: PeerInfo): Uint8Array => {
|
|
210
734
|
return encodeMessage(obj, PeerInfo.codec())
|
|
211
735
|
}
|
|
212
736
|
|