@libp2p/floodsub 3.0.1 → 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 +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/message/rpc.d.ts +20 -18
- 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 +18 -13
- package/src/index.ts +3 -2
- package/src/message/rpc.ts +588 -61
package/src/message/rpc.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/* eslint-disable import/export */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
3
|
|
|
4
|
-
import { encodeMessage, decodeMessage, message
|
|
4
|
+
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
|
|
5
|
+
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
6
|
+
import type { Codec } from 'protons-runtime'
|
|
5
7
|
|
|
6
8
|
export interface RPC {
|
|
7
9
|
subscriptions: RPC.SubOpts[]
|
|
@@ -16,21 +18,65 @@ export namespace RPC {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export namespace SubOpts {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
let _codec: Codec<SubOpts>
|
|
22
|
+
|
|
23
|
+
export const codec = (): Codec<SubOpts> => {
|
|
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
|
|
24
69
|
}
|
|
25
70
|
|
|
26
71
|
export const encode = (obj: SubOpts): Uint8Array => {
|
|
27
72
|
return encodeMessage(obj, SubOpts.codec())
|
|
28
73
|
}
|
|
29
74
|
|
|
30
|
-
export const decode = (buf: Uint8Array): SubOpts => {
|
|
75
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList): SubOpts => {
|
|
31
76
|
return decodeMessage(buf, SubOpts.codec())
|
|
32
77
|
}
|
|
33
78
|
}
|
|
79
|
+
|
|
34
80
|
export interface Message {
|
|
35
81
|
from?: Uint8Array
|
|
36
82
|
data?: Uint8Array
|
|
@@ -41,39 +87,181 @@ export namespace RPC {
|
|
|
41
87
|
}
|
|
42
88
|
|
|
43
89
|
export namespace Message {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
90
|
+
let _codec: Codec<Message>
|
|
91
|
+
|
|
92
|
+
export const codec = (): Codec<Message> => {
|
|
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
|
|
53
170
|
}
|
|
54
171
|
|
|
55
172
|
export const encode = (obj: Message): Uint8Array => {
|
|
56
173
|
return encodeMessage(obj, Message.codec())
|
|
57
174
|
}
|
|
58
175
|
|
|
59
|
-
export const decode = (buf: Uint8Array): Message => {
|
|
176
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList): Message => {
|
|
60
177
|
return decodeMessage(buf, Message.codec())
|
|
61
178
|
}
|
|
62
179
|
}
|
|
63
180
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
181
|
+
let _codec: Codec<RPC>
|
|
182
|
+
|
|
183
|
+
export const codec = (): Codec<RPC> => {
|
|
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
|
|
70
258
|
}
|
|
71
259
|
|
|
72
260
|
export const encode = (obj: RPC): Uint8Array => {
|
|
73
261
|
return encodeMessage(obj, RPC.codec())
|
|
74
262
|
}
|
|
75
263
|
|
|
76
|
-
export const decode = (buf: Uint8Array): RPC => {
|
|
264
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList): RPC => {
|
|
77
265
|
return decodeMessage(buf, RPC.codec())
|
|
78
266
|
}
|
|
79
267
|
}
|
|
@@ -86,20 +274,118 @@ export interface ControlMessage {
|
|
|
86
274
|
}
|
|
87
275
|
|
|
88
276
|
export namespace ControlMessage {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
277
|
+
let _codec: Codec<ControlMessage>
|
|
278
|
+
|
|
279
|
+
export const codec = (): Codec<ControlMessage> => {
|
|
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
|
|
96
382
|
}
|
|
97
383
|
|
|
98
384
|
export const encode = (obj: ControlMessage): Uint8Array => {
|
|
99
385
|
return encodeMessage(obj, ControlMessage.codec())
|
|
100
386
|
}
|
|
101
387
|
|
|
102
|
-
export const decode = (buf: Uint8Array): ControlMessage => {
|
|
388
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlMessage => {
|
|
103
389
|
return decodeMessage(buf, ControlMessage.codec())
|
|
104
390
|
}
|
|
105
391
|
}
|
|
@@ -110,18 +396,72 @@ export interface ControlIHave {
|
|
|
110
396
|
}
|
|
111
397
|
|
|
112
398
|
export namespace ControlIHave {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
399
|
+
let _codec: Codec<ControlIHave>
|
|
400
|
+
|
|
401
|
+
export const codec = (): Codec<ControlIHave> => {
|
|
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
|
|
118
458
|
}
|
|
119
459
|
|
|
120
460
|
export const encode = (obj: ControlIHave): Uint8Array => {
|
|
121
461
|
return encodeMessage(obj, ControlIHave.codec())
|
|
122
462
|
}
|
|
123
463
|
|
|
124
|
-
export const decode = (buf: Uint8Array): ControlIHave => {
|
|
464
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlIHave => {
|
|
125
465
|
return decodeMessage(buf, ControlIHave.codec())
|
|
126
466
|
}
|
|
127
467
|
}
|
|
@@ -131,17 +471,64 @@ export interface ControlIWant {
|
|
|
131
471
|
}
|
|
132
472
|
|
|
133
473
|
export namespace ControlIWant {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
474
|
+
let _codec: Codec<ControlIWant>
|
|
475
|
+
|
|
476
|
+
export const codec = (): Codec<ControlIWant> => {
|
|
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
|
|
138
525
|
}
|
|
139
526
|
|
|
140
527
|
export const encode = (obj: ControlIWant): Uint8Array => {
|
|
141
528
|
return encodeMessage(obj, ControlIWant.codec())
|
|
142
529
|
}
|
|
143
530
|
|
|
144
|
-
export const decode = (buf: Uint8Array): ControlIWant => {
|
|
531
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlIWant => {
|
|
145
532
|
return decodeMessage(buf, ControlIWant.codec())
|
|
146
533
|
}
|
|
147
534
|
}
|
|
@@ -151,17 +538,53 @@ export interface ControlGraft {
|
|
|
151
538
|
}
|
|
152
539
|
|
|
153
540
|
export namespace ControlGraft {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
541
|
+
let _codec: Codec<ControlGraft>
|
|
542
|
+
|
|
543
|
+
export const codec = (): Codec<ControlGraft> => {
|
|
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
|
|
158
581
|
}
|
|
159
582
|
|
|
160
583
|
export const encode = (obj: ControlGraft): Uint8Array => {
|
|
161
584
|
return encodeMessage(obj, ControlGraft.codec())
|
|
162
585
|
}
|
|
163
586
|
|
|
164
|
-
export const decode = (buf: Uint8Array): ControlGraft => {
|
|
587
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlGraft => {
|
|
165
588
|
return decodeMessage(buf, ControlGraft.codec())
|
|
166
589
|
}
|
|
167
590
|
}
|
|
@@ -173,19 +596,80 @@ export interface ControlPrune {
|
|
|
173
596
|
}
|
|
174
597
|
|
|
175
598
|
export namespace ControlPrune {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
599
|
+
let _codec: Codec<ControlPrune>
|
|
600
|
+
|
|
601
|
+
export const codec = (): Codec<ControlPrune> => {
|
|
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
|
|
182
666
|
}
|
|
183
667
|
|
|
184
668
|
export const encode = (obj: ControlPrune): Uint8Array => {
|
|
185
669
|
return encodeMessage(obj, ControlPrune.codec())
|
|
186
670
|
}
|
|
187
671
|
|
|
188
|
-
export const decode = (buf: Uint8Array): ControlPrune => {
|
|
672
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList): ControlPrune => {
|
|
189
673
|
return decodeMessage(buf, ControlPrune.codec())
|
|
190
674
|
}
|
|
191
675
|
}
|
|
@@ -196,18 +680,61 @@ export interface PeerInfo {
|
|
|
196
680
|
}
|
|
197
681
|
|
|
198
682
|
export namespace PeerInfo {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
683
|
+
let _codec: Codec<PeerInfo>
|
|
684
|
+
|
|
685
|
+
export const codec = (): Codec<PeerInfo> => {
|
|
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
|
|
204
731
|
}
|
|
205
732
|
|
|
206
733
|
export const encode = (obj: PeerInfo): Uint8Array => {
|
|
207
734
|
return encodeMessage(obj, PeerInfo.codec())
|
|
208
735
|
}
|
|
209
736
|
|
|
210
|
-
export const decode = (buf: Uint8Array): PeerInfo => {
|
|
737
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList): PeerInfo => {
|
|
211
738
|
return decodeMessage(buf, PeerInfo.codec())
|
|
212
739
|
}
|
|
213
740
|
}
|