@libp2p/daemon-protocol 3.0.2 → 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/README.md +3 -9
- package/dist/src/index.d.ts +7 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +233 -344
- package/dist/src/index.js.map +1 -1
- package/dist/src/stream-handler.d.ts +2 -2
- package/dist/src/stream-handler.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.proto +40 -7
- package/src/index.ts +240 -340
- package/src/stream-handler.ts +3 -3
package/src/index.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/* eslint-disable import/export */
|
|
2
|
+
/* eslint-disable complexity */
|
|
2
3
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
|
3
5
|
|
|
4
6
|
import { enumeration, encodeMessage, decodeMessage, message } from 'protons-runtime'
|
|
5
7
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
6
8
|
import type { Codec } from 'protons-runtime'
|
|
7
9
|
|
|
8
10
|
export interface Request {
|
|
9
|
-
type
|
|
11
|
+
type?: Request.Type
|
|
10
12
|
connect?: ConnectRequest
|
|
11
13
|
streamOpen?: StreamOpenRequest
|
|
12
14
|
streamHandler?: StreamHandlerRequest
|
|
@@ -54,65 +56,77 @@ export namespace Request {
|
|
|
54
56
|
|
|
55
57
|
export const codec = (): Codec<Request> => {
|
|
56
58
|
if (_codec == null) {
|
|
57
|
-
_codec = message<Request>((obj,
|
|
59
|
+
_codec = message<Request>((obj, w, opts = {}) => {
|
|
58
60
|
if (opts.lengthDelimited !== false) {
|
|
59
|
-
|
|
61
|
+
w.fork()
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
if (obj.type != null) {
|
|
63
|
-
|
|
64
|
-
Request.Type.codec().encode(obj.type,
|
|
65
|
-
} else {
|
|
66
|
-
throw new Error('Protocol error: required field "type" was not found in object')
|
|
65
|
+
w.uint32(8)
|
|
66
|
+
Request.Type.codec().encode(obj.type, w)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
if (obj.connect != null) {
|
|
70
|
-
|
|
71
|
-
ConnectRequest.codec().encode(obj.connect,
|
|
70
|
+
w.uint32(18)
|
|
71
|
+
ConnectRequest.codec().encode(obj.connect, w, {
|
|
72
|
+
writeDefaults: false
|
|
73
|
+
})
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
if (obj.streamOpen != null) {
|
|
75
|
-
|
|
76
|
-
StreamOpenRequest.codec().encode(obj.streamOpen,
|
|
77
|
+
w.uint32(26)
|
|
78
|
+
StreamOpenRequest.codec().encode(obj.streamOpen, w, {
|
|
79
|
+
writeDefaults: false
|
|
80
|
+
})
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
if (obj.streamHandler != null) {
|
|
80
|
-
|
|
81
|
-
StreamHandlerRequest.codec().encode(obj.streamHandler,
|
|
84
|
+
w.uint32(34)
|
|
85
|
+
StreamHandlerRequest.codec().encode(obj.streamHandler, w, {
|
|
86
|
+
writeDefaults: false
|
|
87
|
+
})
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
if (obj.dht != null) {
|
|
85
|
-
|
|
86
|
-
DHTRequest.codec().encode(obj.dht,
|
|
91
|
+
w.uint32(42)
|
|
92
|
+
DHTRequest.codec().encode(obj.dht, w, {
|
|
93
|
+
writeDefaults: false
|
|
94
|
+
})
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
if (obj.connManager != null) {
|
|
90
|
-
|
|
91
|
-
ConnManagerRequest.codec().encode(obj.connManager,
|
|
98
|
+
w.uint32(50)
|
|
99
|
+
ConnManagerRequest.codec().encode(obj.connManager, w, {
|
|
100
|
+
writeDefaults: false
|
|
101
|
+
})
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
if (obj.disconnect != null) {
|
|
95
|
-
|
|
96
|
-
DisconnectRequest.codec().encode(obj.disconnect,
|
|
105
|
+
w.uint32(58)
|
|
106
|
+
DisconnectRequest.codec().encode(obj.disconnect, w, {
|
|
107
|
+
writeDefaults: false
|
|
108
|
+
})
|
|
97
109
|
}
|
|
98
110
|
|
|
99
111
|
if (obj.pubsub != null) {
|
|
100
|
-
|
|
101
|
-
PSRequest.codec().encode(obj.pubsub,
|
|
112
|
+
w.uint32(66)
|
|
113
|
+
PSRequest.codec().encode(obj.pubsub, w, {
|
|
114
|
+
writeDefaults: false
|
|
115
|
+
})
|
|
102
116
|
}
|
|
103
117
|
|
|
104
118
|
if (obj.peerStore != null) {
|
|
105
|
-
|
|
106
|
-
PeerstoreRequest.codec().encode(obj.peerStore,
|
|
119
|
+
w.uint32(74)
|
|
120
|
+
PeerstoreRequest.codec().encode(obj.peerStore, w, {
|
|
121
|
+
writeDefaults: false
|
|
122
|
+
})
|
|
107
123
|
}
|
|
108
124
|
|
|
109
125
|
if (opts.lengthDelimited !== false) {
|
|
110
|
-
|
|
126
|
+
w.ldelim()
|
|
111
127
|
}
|
|
112
128
|
}, (reader, length) => {
|
|
113
|
-
const obj: any = {
|
|
114
|
-
type: Type.IDENTIFY
|
|
115
|
-
}
|
|
129
|
+
const obj: any = {}
|
|
116
130
|
|
|
117
131
|
const end = length == null ? reader.len : reader.pos + length
|
|
118
132
|
|
|
@@ -153,10 +167,6 @@ export namespace Request {
|
|
|
153
167
|
}
|
|
154
168
|
}
|
|
155
169
|
|
|
156
|
-
if (obj.type == null) {
|
|
157
|
-
throw new Error('Protocol error: value for required field "type" was not found in protobuf')
|
|
158
|
-
}
|
|
159
|
-
|
|
160
170
|
return obj
|
|
161
171
|
})
|
|
162
172
|
}
|
|
@@ -174,7 +184,7 @@ export namespace Request {
|
|
|
174
184
|
}
|
|
175
185
|
|
|
176
186
|
export interface Response {
|
|
177
|
-
type
|
|
187
|
+
type?: Response.Type
|
|
178
188
|
error?: ErrorResponse
|
|
179
189
|
streamInfo?: StreamInfo
|
|
180
190
|
identify?: IdentifyResponse
|
|
@@ -205,63 +215,72 @@ export namespace Response {
|
|
|
205
215
|
|
|
206
216
|
export const codec = (): Codec<Response> => {
|
|
207
217
|
if (_codec == null) {
|
|
208
|
-
_codec = message<Response>((obj,
|
|
218
|
+
_codec = message<Response>((obj, w, opts = {}) => {
|
|
209
219
|
if (opts.lengthDelimited !== false) {
|
|
210
|
-
|
|
220
|
+
w.fork()
|
|
211
221
|
}
|
|
212
222
|
|
|
213
223
|
if (obj.type != null) {
|
|
214
|
-
|
|
215
|
-
Response.Type.codec().encode(obj.type,
|
|
216
|
-
} else {
|
|
217
|
-
throw new Error('Protocol error: required field "type" was not found in object')
|
|
224
|
+
w.uint32(8)
|
|
225
|
+
Response.Type.codec().encode(obj.type, w)
|
|
218
226
|
}
|
|
219
227
|
|
|
220
228
|
if (obj.error != null) {
|
|
221
|
-
|
|
222
|
-
ErrorResponse.codec().encode(obj.error,
|
|
229
|
+
w.uint32(18)
|
|
230
|
+
ErrorResponse.codec().encode(obj.error, w, {
|
|
231
|
+
writeDefaults: false
|
|
232
|
+
})
|
|
223
233
|
}
|
|
224
234
|
|
|
225
235
|
if (obj.streamInfo != null) {
|
|
226
|
-
|
|
227
|
-
StreamInfo.codec().encode(obj.streamInfo,
|
|
236
|
+
w.uint32(26)
|
|
237
|
+
StreamInfo.codec().encode(obj.streamInfo, w, {
|
|
238
|
+
writeDefaults: false
|
|
239
|
+
})
|
|
228
240
|
}
|
|
229
241
|
|
|
230
242
|
if (obj.identify != null) {
|
|
231
|
-
|
|
232
|
-
IdentifyResponse.codec().encode(obj.identify,
|
|
243
|
+
w.uint32(34)
|
|
244
|
+
IdentifyResponse.codec().encode(obj.identify, w, {
|
|
245
|
+
writeDefaults: false
|
|
246
|
+
})
|
|
233
247
|
}
|
|
234
248
|
|
|
235
249
|
if (obj.dht != null) {
|
|
236
|
-
|
|
237
|
-
DHTResponse.codec().encode(obj.dht,
|
|
250
|
+
w.uint32(42)
|
|
251
|
+
DHTResponse.codec().encode(obj.dht, w, {
|
|
252
|
+
writeDefaults: false
|
|
253
|
+
})
|
|
238
254
|
}
|
|
239
255
|
|
|
240
256
|
if (obj.peers != null) {
|
|
241
257
|
for (const value of obj.peers) {
|
|
242
|
-
|
|
243
|
-
PeerInfo.codec().encode(value,
|
|
258
|
+
w.uint32(50)
|
|
259
|
+
PeerInfo.codec().encode(value, w, {
|
|
260
|
+
writeDefaults: true
|
|
261
|
+
})
|
|
244
262
|
}
|
|
245
|
-
} else {
|
|
246
|
-
throw new Error('Protocol error: required field "peers" was not found in object')
|
|
247
263
|
}
|
|
248
264
|
|
|
249
265
|
if (obj.pubsub != null) {
|
|
250
|
-
|
|
251
|
-
PSResponse.codec().encode(obj.pubsub,
|
|
266
|
+
w.uint32(58)
|
|
267
|
+
PSResponse.codec().encode(obj.pubsub, w, {
|
|
268
|
+
writeDefaults: false
|
|
269
|
+
})
|
|
252
270
|
}
|
|
253
271
|
|
|
254
272
|
if (obj.peerStore != null) {
|
|
255
|
-
|
|
256
|
-
PeerstoreResponse.codec().encode(obj.peerStore,
|
|
273
|
+
w.uint32(66)
|
|
274
|
+
PeerstoreResponse.codec().encode(obj.peerStore, w, {
|
|
275
|
+
writeDefaults: false
|
|
276
|
+
})
|
|
257
277
|
}
|
|
258
278
|
|
|
259
279
|
if (opts.lengthDelimited !== false) {
|
|
260
|
-
|
|
280
|
+
w.ldelim()
|
|
261
281
|
}
|
|
262
282
|
}, (reader, length) => {
|
|
263
283
|
const obj: any = {
|
|
264
|
-
type: Type.OK,
|
|
265
284
|
peers: []
|
|
266
285
|
}
|
|
267
286
|
|
|
@@ -301,10 +320,6 @@ export namespace Response {
|
|
|
301
320
|
}
|
|
302
321
|
}
|
|
303
322
|
|
|
304
|
-
if (obj.type == null) {
|
|
305
|
-
throw new Error('Protocol error: value for required field "type" was not found in protobuf')
|
|
306
|
-
}
|
|
307
|
-
|
|
308
323
|
return obj
|
|
309
324
|
})
|
|
310
325
|
}
|
|
@@ -331,29 +346,25 @@ export namespace IdentifyResponse {
|
|
|
331
346
|
|
|
332
347
|
export const codec = (): Codec<IdentifyResponse> => {
|
|
333
348
|
if (_codec == null) {
|
|
334
|
-
_codec = message<IdentifyResponse>((obj,
|
|
349
|
+
_codec = message<IdentifyResponse>((obj, w, opts = {}) => {
|
|
335
350
|
if (opts.lengthDelimited !== false) {
|
|
336
|
-
|
|
351
|
+
w.fork()
|
|
337
352
|
}
|
|
338
353
|
|
|
339
|
-
if (obj.id != null) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
} else {
|
|
343
|
-
throw new Error('Protocol error: required field "id" was not found in object')
|
|
354
|
+
if (opts.writeDefaults === true || (obj.id != null && obj.id.byteLength > 0)) {
|
|
355
|
+
w.uint32(10)
|
|
356
|
+
w.bytes(obj.id)
|
|
344
357
|
}
|
|
345
358
|
|
|
346
359
|
if (obj.addrs != null) {
|
|
347
360
|
for (const value of obj.addrs) {
|
|
348
|
-
|
|
349
|
-
|
|
361
|
+
w.uint32(18)
|
|
362
|
+
w.bytes(value)
|
|
350
363
|
}
|
|
351
|
-
} else {
|
|
352
|
-
throw new Error('Protocol error: required field "addrs" was not found in object')
|
|
353
364
|
}
|
|
354
365
|
|
|
355
366
|
if (opts.lengthDelimited !== false) {
|
|
356
|
-
|
|
367
|
+
w.ldelim()
|
|
357
368
|
}
|
|
358
369
|
}, (reader, length) => {
|
|
359
370
|
const obj: any = {
|
|
@@ -379,10 +390,6 @@ export namespace IdentifyResponse {
|
|
|
379
390
|
}
|
|
380
391
|
}
|
|
381
392
|
|
|
382
|
-
if (obj.id == null) {
|
|
383
|
-
throw new Error('Protocol error: value for required field "id" was not found in protobuf')
|
|
384
|
-
}
|
|
385
|
-
|
|
386
393
|
return obj
|
|
387
394
|
})
|
|
388
395
|
}
|
|
@@ -410,34 +417,30 @@ export namespace ConnectRequest {
|
|
|
410
417
|
|
|
411
418
|
export const codec = (): Codec<ConnectRequest> => {
|
|
412
419
|
if (_codec == null) {
|
|
413
|
-
_codec = message<ConnectRequest>((obj,
|
|
420
|
+
_codec = message<ConnectRequest>((obj, w, opts = {}) => {
|
|
414
421
|
if (opts.lengthDelimited !== false) {
|
|
415
|
-
|
|
422
|
+
w.fork()
|
|
416
423
|
}
|
|
417
424
|
|
|
418
|
-
if (obj.peer != null) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
} else {
|
|
422
|
-
throw new Error('Protocol error: required field "peer" was not found in object')
|
|
425
|
+
if (opts.writeDefaults === true || (obj.peer != null && obj.peer.byteLength > 0)) {
|
|
426
|
+
w.uint32(10)
|
|
427
|
+
w.bytes(obj.peer)
|
|
423
428
|
}
|
|
424
429
|
|
|
425
430
|
if (obj.addrs != null) {
|
|
426
431
|
for (const value of obj.addrs) {
|
|
427
|
-
|
|
428
|
-
|
|
432
|
+
w.uint32(18)
|
|
433
|
+
w.bytes(value)
|
|
429
434
|
}
|
|
430
|
-
} else {
|
|
431
|
-
throw new Error('Protocol error: required field "addrs" was not found in object')
|
|
432
435
|
}
|
|
433
436
|
|
|
434
437
|
if (obj.timeout != null) {
|
|
435
|
-
|
|
436
|
-
|
|
438
|
+
w.uint32(24)
|
|
439
|
+
w.int64(obj.timeout)
|
|
437
440
|
}
|
|
438
441
|
|
|
439
442
|
if (opts.lengthDelimited !== false) {
|
|
440
|
-
|
|
443
|
+
w.ldelim()
|
|
441
444
|
}
|
|
442
445
|
}, (reader, length) => {
|
|
443
446
|
const obj: any = {
|
|
@@ -466,10 +469,6 @@ export namespace ConnectRequest {
|
|
|
466
469
|
}
|
|
467
470
|
}
|
|
468
471
|
|
|
469
|
-
if (obj.peer == null) {
|
|
470
|
-
throw new Error('Protocol error: value for required field "peer" was not found in protobuf')
|
|
471
|
-
}
|
|
472
|
-
|
|
473
472
|
return obj
|
|
474
473
|
})
|
|
475
474
|
}
|
|
@@ -497,34 +496,30 @@ export namespace StreamOpenRequest {
|
|
|
497
496
|
|
|
498
497
|
export const codec = (): Codec<StreamOpenRequest> => {
|
|
499
498
|
if (_codec == null) {
|
|
500
|
-
_codec = message<StreamOpenRequest>((obj,
|
|
499
|
+
_codec = message<StreamOpenRequest>((obj, w, opts = {}) => {
|
|
501
500
|
if (opts.lengthDelimited !== false) {
|
|
502
|
-
|
|
501
|
+
w.fork()
|
|
503
502
|
}
|
|
504
503
|
|
|
505
|
-
if (obj.peer != null) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
} else {
|
|
509
|
-
throw new Error('Protocol error: required field "peer" was not found in object')
|
|
504
|
+
if (opts.writeDefaults === true || (obj.peer != null && obj.peer.byteLength > 0)) {
|
|
505
|
+
w.uint32(10)
|
|
506
|
+
w.bytes(obj.peer)
|
|
510
507
|
}
|
|
511
508
|
|
|
512
509
|
if (obj.proto != null) {
|
|
513
510
|
for (const value of obj.proto) {
|
|
514
|
-
|
|
515
|
-
|
|
511
|
+
w.uint32(18)
|
|
512
|
+
w.string(value)
|
|
516
513
|
}
|
|
517
|
-
} else {
|
|
518
|
-
throw new Error('Protocol error: required field "proto" was not found in object')
|
|
519
514
|
}
|
|
520
515
|
|
|
521
516
|
if (obj.timeout != null) {
|
|
522
|
-
|
|
523
|
-
|
|
517
|
+
w.uint32(24)
|
|
518
|
+
w.int64(obj.timeout)
|
|
524
519
|
}
|
|
525
520
|
|
|
526
521
|
if (opts.lengthDelimited !== false) {
|
|
527
|
-
|
|
522
|
+
w.ldelim()
|
|
528
523
|
}
|
|
529
524
|
}, (reader, length) => {
|
|
530
525
|
const obj: any = {
|
|
@@ -553,10 +548,6 @@ export namespace StreamOpenRequest {
|
|
|
553
548
|
}
|
|
554
549
|
}
|
|
555
550
|
|
|
556
|
-
if (obj.peer == null) {
|
|
557
|
-
throw new Error('Protocol error: value for required field "peer" was not found in protobuf')
|
|
558
|
-
}
|
|
559
|
-
|
|
560
551
|
return obj
|
|
561
552
|
})
|
|
562
553
|
}
|
|
@@ -583,29 +574,25 @@ export namespace StreamHandlerRequest {
|
|
|
583
574
|
|
|
584
575
|
export const codec = (): Codec<StreamHandlerRequest> => {
|
|
585
576
|
if (_codec == null) {
|
|
586
|
-
_codec = message<StreamHandlerRequest>((obj,
|
|
577
|
+
_codec = message<StreamHandlerRequest>((obj, w, opts = {}) => {
|
|
587
578
|
if (opts.lengthDelimited !== false) {
|
|
588
|
-
|
|
579
|
+
w.fork()
|
|
589
580
|
}
|
|
590
581
|
|
|
591
|
-
if (obj.addr != null) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
} else {
|
|
595
|
-
throw new Error('Protocol error: required field "addr" was not found in object')
|
|
582
|
+
if (opts.writeDefaults === true || (obj.addr != null && obj.addr.byteLength > 0)) {
|
|
583
|
+
w.uint32(10)
|
|
584
|
+
w.bytes(obj.addr)
|
|
596
585
|
}
|
|
597
586
|
|
|
598
587
|
if (obj.proto != null) {
|
|
599
588
|
for (const value of obj.proto) {
|
|
600
|
-
|
|
601
|
-
|
|
589
|
+
w.uint32(18)
|
|
590
|
+
w.string(value)
|
|
602
591
|
}
|
|
603
|
-
} else {
|
|
604
|
-
throw new Error('Protocol error: required field "proto" was not found in object')
|
|
605
592
|
}
|
|
606
593
|
|
|
607
594
|
if (opts.lengthDelimited !== false) {
|
|
608
|
-
|
|
595
|
+
w.ldelim()
|
|
609
596
|
}
|
|
610
597
|
}, (reader, length) => {
|
|
611
598
|
const obj: any = {
|
|
@@ -631,10 +618,6 @@ export namespace StreamHandlerRequest {
|
|
|
631
618
|
}
|
|
632
619
|
}
|
|
633
620
|
|
|
634
|
-
if (obj.addr == null) {
|
|
635
|
-
throw new Error('Protocol error: value for required field "addr" was not found in protobuf')
|
|
636
|
-
}
|
|
637
|
-
|
|
638
621
|
return obj
|
|
639
622
|
})
|
|
640
623
|
}
|
|
@@ -660,20 +643,18 @@ export namespace ErrorResponse {
|
|
|
660
643
|
|
|
661
644
|
export const codec = (): Codec<ErrorResponse> => {
|
|
662
645
|
if (_codec == null) {
|
|
663
|
-
_codec = message<ErrorResponse>((obj,
|
|
646
|
+
_codec = message<ErrorResponse>((obj, w, opts = {}) => {
|
|
664
647
|
if (opts.lengthDelimited !== false) {
|
|
665
|
-
|
|
648
|
+
w.fork()
|
|
666
649
|
}
|
|
667
650
|
|
|
668
|
-
if (obj.msg
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
} else {
|
|
672
|
-
throw new Error('Protocol error: required field "msg" was not found in object')
|
|
651
|
+
if (opts.writeDefaults === true || obj.msg !== '') {
|
|
652
|
+
w.uint32(10)
|
|
653
|
+
w.string(obj.msg)
|
|
673
654
|
}
|
|
674
655
|
|
|
675
656
|
if (opts.lengthDelimited !== false) {
|
|
676
|
-
|
|
657
|
+
w.ldelim()
|
|
677
658
|
}
|
|
678
659
|
}, (reader, length) => {
|
|
679
660
|
const obj: any = {
|
|
@@ -695,10 +676,6 @@ export namespace ErrorResponse {
|
|
|
695
676
|
}
|
|
696
677
|
}
|
|
697
678
|
|
|
698
|
-
if (obj.msg == null) {
|
|
699
|
-
throw new Error('Protocol error: value for required field "msg" was not found in protobuf')
|
|
700
|
-
}
|
|
701
|
-
|
|
702
679
|
return obj
|
|
703
680
|
})
|
|
704
681
|
}
|
|
@@ -726,34 +703,28 @@ export namespace StreamInfo {
|
|
|
726
703
|
|
|
727
704
|
export const codec = (): Codec<StreamInfo> => {
|
|
728
705
|
if (_codec == null) {
|
|
729
|
-
_codec = message<StreamInfo>((obj,
|
|
706
|
+
_codec = message<StreamInfo>((obj, w, opts = {}) => {
|
|
730
707
|
if (opts.lengthDelimited !== false) {
|
|
731
|
-
|
|
708
|
+
w.fork()
|
|
732
709
|
}
|
|
733
710
|
|
|
734
|
-
if (obj.peer != null) {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
} else {
|
|
738
|
-
throw new Error('Protocol error: required field "peer" was not found in object')
|
|
711
|
+
if (opts.writeDefaults === true || (obj.peer != null && obj.peer.byteLength > 0)) {
|
|
712
|
+
w.uint32(10)
|
|
713
|
+
w.bytes(obj.peer)
|
|
739
714
|
}
|
|
740
715
|
|
|
741
|
-
if (obj.addr != null) {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
} else {
|
|
745
|
-
throw new Error('Protocol error: required field "addr" was not found in object')
|
|
716
|
+
if (opts.writeDefaults === true || (obj.addr != null && obj.addr.byteLength > 0)) {
|
|
717
|
+
w.uint32(18)
|
|
718
|
+
w.bytes(obj.addr)
|
|
746
719
|
}
|
|
747
720
|
|
|
748
|
-
if (obj.proto
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
} else {
|
|
752
|
-
throw new Error('Protocol error: required field "proto" was not found in object')
|
|
721
|
+
if (opts.writeDefaults === true || obj.proto !== '') {
|
|
722
|
+
w.uint32(26)
|
|
723
|
+
w.string(obj.proto)
|
|
753
724
|
}
|
|
754
725
|
|
|
755
726
|
if (opts.lengthDelimited !== false) {
|
|
756
|
-
|
|
727
|
+
w.ldelim()
|
|
757
728
|
}
|
|
758
729
|
}, (reader, length) => {
|
|
759
730
|
const obj: any = {
|
|
@@ -783,18 +754,6 @@ export namespace StreamInfo {
|
|
|
783
754
|
}
|
|
784
755
|
}
|
|
785
756
|
|
|
786
|
-
if (obj.peer == null) {
|
|
787
|
-
throw new Error('Protocol error: value for required field "peer" was not found in protobuf')
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
if (obj.addr == null) {
|
|
791
|
-
throw new Error('Protocol error: value for required field "addr" was not found in protobuf')
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
if (obj.proto == null) {
|
|
795
|
-
throw new Error('Protocol error: value for required field "proto" was not found in protobuf')
|
|
796
|
-
}
|
|
797
|
-
|
|
798
757
|
return obj
|
|
799
758
|
})
|
|
800
759
|
}
|
|
@@ -812,7 +771,7 @@ export namespace StreamInfo {
|
|
|
812
771
|
}
|
|
813
772
|
|
|
814
773
|
export interface DHTRequest {
|
|
815
|
-
type
|
|
774
|
+
type?: DHTRequest.Type
|
|
816
775
|
peer?: Uint8Array
|
|
817
776
|
cid?: Uint8Array
|
|
818
777
|
key?: Uint8Array
|
|
@@ -856,55 +815,51 @@ export namespace DHTRequest {
|
|
|
856
815
|
|
|
857
816
|
export const codec = (): Codec<DHTRequest> => {
|
|
858
817
|
if (_codec == null) {
|
|
859
|
-
_codec = message<DHTRequest>((obj,
|
|
818
|
+
_codec = message<DHTRequest>((obj, w, opts = {}) => {
|
|
860
819
|
if (opts.lengthDelimited !== false) {
|
|
861
|
-
|
|
820
|
+
w.fork()
|
|
862
821
|
}
|
|
863
822
|
|
|
864
823
|
if (obj.type != null) {
|
|
865
|
-
|
|
866
|
-
DHTRequest.Type.codec().encode(obj.type,
|
|
867
|
-
} else {
|
|
868
|
-
throw new Error('Protocol error: required field "type" was not found in object')
|
|
824
|
+
w.uint32(8)
|
|
825
|
+
DHTRequest.Type.codec().encode(obj.type, w)
|
|
869
826
|
}
|
|
870
827
|
|
|
871
828
|
if (obj.peer != null) {
|
|
872
|
-
|
|
873
|
-
|
|
829
|
+
w.uint32(18)
|
|
830
|
+
w.bytes(obj.peer)
|
|
874
831
|
}
|
|
875
832
|
|
|
876
833
|
if (obj.cid != null) {
|
|
877
|
-
|
|
878
|
-
|
|
834
|
+
w.uint32(26)
|
|
835
|
+
w.bytes(obj.cid)
|
|
879
836
|
}
|
|
880
837
|
|
|
881
838
|
if (obj.key != null) {
|
|
882
|
-
|
|
883
|
-
|
|
839
|
+
w.uint32(34)
|
|
840
|
+
w.bytes(obj.key)
|
|
884
841
|
}
|
|
885
842
|
|
|
886
843
|
if (obj.value != null) {
|
|
887
|
-
|
|
888
|
-
|
|
844
|
+
w.uint32(42)
|
|
845
|
+
w.bytes(obj.value)
|
|
889
846
|
}
|
|
890
847
|
|
|
891
848
|
if (obj.count != null) {
|
|
892
|
-
|
|
893
|
-
|
|
849
|
+
w.uint32(48)
|
|
850
|
+
w.int32(obj.count)
|
|
894
851
|
}
|
|
895
852
|
|
|
896
853
|
if (obj.timeout != null) {
|
|
897
|
-
|
|
898
|
-
|
|
854
|
+
w.uint32(56)
|
|
855
|
+
w.int64(obj.timeout)
|
|
899
856
|
}
|
|
900
857
|
|
|
901
858
|
if (opts.lengthDelimited !== false) {
|
|
902
|
-
|
|
859
|
+
w.ldelim()
|
|
903
860
|
}
|
|
904
861
|
}, (reader, length) => {
|
|
905
|
-
const obj: any = {
|
|
906
|
-
type: Type.FIND_PEER
|
|
907
|
-
}
|
|
862
|
+
const obj: any = {}
|
|
908
863
|
|
|
909
864
|
const end = length == null ? reader.len : reader.pos + length
|
|
910
865
|
|
|
@@ -939,10 +894,6 @@ export namespace DHTRequest {
|
|
|
939
894
|
}
|
|
940
895
|
}
|
|
941
896
|
|
|
942
|
-
if (obj.type == null) {
|
|
943
|
-
throw new Error('Protocol error: value for required field "type" was not found in protobuf')
|
|
944
|
-
}
|
|
945
|
-
|
|
946
897
|
return obj
|
|
947
898
|
})
|
|
948
899
|
}
|
|
@@ -960,7 +911,7 @@ export namespace DHTRequest {
|
|
|
960
911
|
}
|
|
961
912
|
|
|
962
913
|
export interface DHTResponse {
|
|
963
|
-
type
|
|
914
|
+
type?: DHTResponse.Type
|
|
964
915
|
peer?: PeerInfo
|
|
965
916
|
value?: Uint8Array
|
|
966
917
|
}
|
|
@@ -988,35 +939,33 @@ export namespace DHTResponse {
|
|
|
988
939
|
|
|
989
940
|
export const codec = (): Codec<DHTResponse> => {
|
|
990
941
|
if (_codec == null) {
|
|
991
|
-
_codec = message<DHTResponse>((obj,
|
|
942
|
+
_codec = message<DHTResponse>((obj, w, opts = {}) => {
|
|
992
943
|
if (opts.lengthDelimited !== false) {
|
|
993
|
-
|
|
944
|
+
w.fork()
|
|
994
945
|
}
|
|
995
946
|
|
|
996
947
|
if (obj.type != null) {
|
|
997
|
-
|
|
998
|
-
DHTResponse.Type.codec().encode(obj.type,
|
|
999
|
-
} else {
|
|
1000
|
-
throw new Error('Protocol error: required field "type" was not found in object')
|
|
948
|
+
w.uint32(8)
|
|
949
|
+
DHTResponse.Type.codec().encode(obj.type, w)
|
|
1001
950
|
}
|
|
1002
951
|
|
|
1003
952
|
if (obj.peer != null) {
|
|
1004
|
-
|
|
1005
|
-
PeerInfo.codec().encode(obj.peer,
|
|
953
|
+
w.uint32(18)
|
|
954
|
+
PeerInfo.codec().encode(obj.peer, w, {
|
|
955
|
+
writeDefaults: false
|
|
956
|
+
})
|
|
1006
957
|
}
|
|
1007
958
|
|
|
1008
959
|
if (obj.value != null) {
|
|
1009
|
-
|
|
1010
|
-
|
|
960
|
+
w.uint32(26)
|
|
961
|
+
w.bytes(obj.value)
|
|
1011
962
|
}
|
|
1012
963
|
|
|
1013
964
|
if (opts.lengthDelimited !== false) {
|
|
1014
|
-
|
|
965
|
+
w.ldelim()
|
|
1015
966
|
}
|
|
1016
967
|
}, (reader, length) => {
|
|
1017
|
-
const obj: any = {
|
|
1018
|
-
type: Type.BEGIN
|
|
1019
|
-
}
|
|
968
|
+
const obj: any = {}
|
|
1020
969
|
|
|
1021
970
|
const end = length == null ? reader.len : reader.pos + length
|
|
1022
971
|
|
|
@@ -1039,10 +988,6 @@ export namespace DHTResponse {
|
|
|
1039
988
|
}
|
|
1040
989
|
}
|
|
1041
990
|
|
|
1042
|
-
if (obj.type == null) {
|
|
1043
|
-
throw new Error('Protocol error: value for required field "type" was not found in protobuf')
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
991
|
return obj
|
|
1047
992
|
})
|
|
1048
993
|
}
|
|
@@ -1069,29 +1014,25 @@ export namespace PeerInfo {
|
|
|
1069
1014
|
|
|
1070
1015
|
export const codec = (): Codec<PeerInfo> => {
|
|
1071
1016
|
if (_codec == null) {
|
|
1072
|
-
_codec = message<PeerInfo>((obj,
|
|
1017
|
+
_codec = message<PeerInfo>((obj, w, opts = {}) => {
|
|
1073
1018
|
if (opts.lengthDelimited !== false) {
|
|
1074
|
-
|
|
1019
|
+
w.fork()
|
|
1075
1020
|
}
|
|
1076
1021
|
|
|
1077
|
-
if (obj.id != null) {
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
} else {
|
|
1081
|
-
throw new Error('Protocol error: required field "id" was not found in object')
|
|
1022
|
+
if (opts.writeDefaults === true || (obj.id != null && obj.id.byteLength > 0)) {
|
|
1023
|
+
w.uint32(10)
|
|
1024
|
+
w.bytes(obj.id)
|
|
1082
1025
|
}
|
|
1083
1026
|
|
|
1084
1027
|
if (obj.addrs != null) {
|
|
1085
1028
|
for (const value of obj.addrs) {
|
|
1086
|
-
|
|
1087
|
-
|
|
1029
|
+
w.uint32(18)
|
|
1030
|
+
w.bytes(value)
|
|
1088
1031
|
}
|
|
1089
|
-
} else {
|
|
1090
|
-
throw new Error('Protocol error: required field "addrs" was not found in object')
|
|
1091
1032
|
}
|
|
1092
1033
|
|
|
1093
1034
|
if (opts.lengthDelimited !== false) {
|
|
1094
|
-
|
|
1035
|
+
w.ldelim()
|
|
1095
1036
|
}
|
|
1096
1037
|
}, (reader, length) => {
|
|
1097
1038
|
const obj: any = {
|
|
@@ -1117,10 +1058,6 @@ export namespace PeerInfo {
|
|
|
1117
1058
|
}
|
|
1118
1059
|
}
|
|
1119
1060
|
|
|
1120
|
-
if (obj.id == null) {
|
|
1121
|
-
throw new Error('Protocol error: value for required field "id" was not found in protobuf')
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
1061
|
return obj
|
|
1125
1062
|
})
|
|
1126
1063
|
}
|
|
@@ -1138,7 +1075,7 @@ export namespace PeerInfo {
|
|
|
1138
1075
|
}
|
|
1139
1076
|
|
|
1140
1077
|
export interface ConnManagerRequest {
|
|
1141
|
-
type
|
|
1078
|
+
type?: ConnManagerRequest.Type
|
|
1142
1079
|
peer?: Uint8Array
|
|
1143
1080
|
tag?: string
|
|
1144
1081
|
weight?: bigint
|
|
@@ -1167,40 +1104,36 @@ export namespace ConnManagerRequest {
|
|
|
1167
1104
|
|
|
1168
1105
|
export const codec = (): Codec<ConnManagerRequest> => {
|
|
1169
1106
|
if (_codec == null) {
|
|
1170
|
-
_codec = message<ConnManagerRequest>((obj,
|
|
1107
|
+
_codec = message<ConnManagerRequest>((obj, w, opts = {}) => {
|
|
1171
1108
|
if (opts.lengthDelimited !== false) {
|
|
1172
|
-
|
|
1109
|
+
w.fork()
|
|
1173
1110
|
}
|
|
1174
1111
|
|
|
1175
1112
|
if (obj.type != null) {
|
|
1176
|
-
|
|
1177
|
-
ConnManagerRequest.Type.codec().encode(obj.type,
|
|
1178
|
-
} else {
|
|
1179
|
-
throw new Error('Protocol error: required field "type" was not found in object')
|
|
1113
|
+
w.uint32(8)
|
|
1114
|
+
ConnManagerRequest.Type.codec().encode(obj.type, w)
|
|
1180
1115
|
}
|
|
1181
1116
|
|
|
1182
1117
|
if (obj.peer != null) {
|
|
1183
|
-
|
|
1184
|
-
|
|
1118
|
+
w.uint32(18)
|
|
1119
|
+
w.bytes(obj.peer)
|
|
1185
1120
|
}
|
|
1186
1121
|
|
|
1187
1122
|
if (obj.tag != null) {
|
|
1188
|
-
|
|
1189
|
-
|
|
1123
|
+
w.uint32(26)
|
|
1124
|
+
w.string(obj.tag)
|
|
1190
1125
|
}
|
|
1191
1126
|
|
|
1192
1127
|
if (obj.weight != null) {
|
|
1193
|
-
|
|
1194
|
-
|
|
1128
|
+
w.uint32(32)
|
|
1129
|
+
w.int64(obj.weight)
|
|
1195
1130
|
}
|
|
1196
1131
|
|
|
1197
1132
|
if (opts.lengthDelimited !== false) {
|
|
1198
|
-
|
|
1133
|
+
w.ldelim()
|
|
1199
1134
|
}
|
|
1200
1135
|
}, (reader, length) => {
|
|
1201
|
-
const obj: any = {
|
|
1202
|
-
type: Type.TAG_PEER
|
|
1203
|
-
}
|
|
1136
|
+
const obj: any = {}
|
|
1204
1137
|
|
|
1205
1138
|
const end = length == null ? reader.len : reader.pos + length
|
|
1206
1139
|
|
|
@@ -1226,10 +1159,6 @@ export namespace ConnManagerRequest {
|
|
|
1226
1159
|
}
|
|
1227
1160
|
}
|
|
1228
1161
|
|
|
1229
|
-
if (obj.type == null) {
|
|
1230
|
-
throw new Error('Protocol error: value for required field "type" was not found in protobuf')
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
1162
|
return obj
|
|
1234
1163
|
})
|
|
1235
1164
|
}
|
|
@@ -1255,20 +1184,18 @@ export namespace DisconnectRequest {
|
|
|
1255
1184
|
|
|
1256
1185
|
export const codec = (): Codec<DisconnectRequest> => {
|
|
1257
1186
|
if (_codec == null) {
|
|
1258
|
-
_codec = message<DisconnectRequest>((obj,
|
|
1187
|
+
_codec = message<DisconnectRequest>((obj, w, opts = {}) => {
|
|
1259
1188
|
if (opts.lengthDelimited !== false) {
|
|
1260
|
-
|
|
1189
|
+
w.fork()
|
|
1261
1190
|
}
|
|
1262
1191
|
|
|
1263
|
-
if (obj.peer != null) {
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
} else {
|
|
1267
|
-
throw new Error('Protocol error: required field "peer" was not found in object')
|
|
1192
|
+
if (opts.writeDefaults === true || (obj.peer != null && obj.peer.byteLength > 0)) {
|
|
1193
|
+
w.uint32(10)
|
|
1194
|
+
w.bytes(obj.peer)
|
|
1268
1195
|
}
|
|
1269
1196
|
|
|
1270
1197
|
if (opts.lengthDelimited !== false) {
|
|
1271
|
-
|
|
1198
|
+
w.ldelim()
|
|
1272
1199
|
}
|
|
1273
1200
|
}, (reader, length) => {
|
|
1274
1201
|
const obj: any = {
|
|
@@ -1290,10 +1217,6 @@ export namespace DisconnectRequest {
|
|
|
1290
1217
|
}
|
|
1291
1218
|
}
|
|
1292
1219
|
|
|
1293
|
-
if (obj.peer == null) {
|
|
1294
|
-
throw new Error('Protocol error: value for required field "peer" was not found in protobuf')
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
1220
|
return obj
|
|
1298
1221
|
})
|
|
1299
1222
|
}
|
|
@@ -1311,7 +1234,7 @@ export namespace DisconnectRequest {
|
|
|
1311
1234
|
}
|
|
1312
1235
|
|
|
1313
1236
|
export interface PSRequest {
|
|
1314
|
-
type
|
|
1237
|
+
type?: PSRequest.Type
|
|
1315
1238
|
topic?: string
|
|
1316
1239
|
data?: Uint8Array
|
|
1317
1240
|
}
|
|
@@ -1341,35 +1264,31 @@ export namespace PSRequest {
|
|
|
1341
1264
|
|
|
1342
1265
|
export const codec = (): Codec<PSRequest> => {
|
|
1343
1266
|
if (_codec == null) {
|
|
1344
|
-
_codec = message<PSRequest>((obj,
|
|
1267
|
+
_codec = message<PSRequest>((obj, w, opts = {}) => {
|
|
1345
1268
|
if (opts.lengthDelimited !== false) {
|
|
1346
|
-
|
|
1269
|
+
w.fork()
|
|
1347
1270
|
}
|
|
1348
1271
|
|
|
1349
1272
|
if (obj.type != null) {
|
|
1350
|
-
|
|
1351
|
-
PSRequest.Type.codec().encode(obj.type,
|
|
1352
|
-
} else {
|
|
1353
|
-
throw new Error('Protocol error: required field "type" was not found in object')
|
|
1273
|
+
w.uint32(8)
|
|
1274
|
+
PSRequest.Type.codec().encode(obj.type, w)
|
|
1354
1275
|
}
|
|
1355
1276
|
|
|
1356
1277
|
if (obj.topic != null) {
|
|
1357
|
-
|
|
1358
|
-
|
|
1278
|
+
w.uint32(18)
|
|
1279
|
+
w.string(obj.topic)
|
|
1359
1280
|
}
|
|
1360
1281
|
|
|
1361
1282
|
if (obj.data != null) {
|
|
1362
|
-
|
|
1363
|
-
|
|
1283
|
+
w.uint32(26)
|
|
1284
|
+
w.bytes(obj.data)
|
|
1364
1285
|
}
|
|
1365
1286
|
|
|
1366
1287
|
if (opts.lengthDelimited !== false) {
|
|
1367
|
-
|
|
1288
|
+
w.ldelim()
|
|
1368
1289
|
}
|
|
1369
1290
|
}, (reader, length) => {
|
|
1370
|
-
const obj: any = {
|
|
1371
|
-
type: Type.GET_TOPICS
|
|
1372
|
-
}
|
|
1291
|
+
const obj: any = {}
|
|
1373
1292
|
|
|
1374
1293
|
const end = length == null ? reader.len : reader.pos + length
|
|
1375
1294
|
|
|
@@ -1392,10 +1311,6 @@ export namespace PSRequest {
|
|
|
1392
1311
|
}
|
|
1393
1312
|
}
|
|
1394
1313
|
|
|
1395
|
-
if (obj.type == null) {
|
|
1396
|
-
throw new Error('Protocol error: value for required field "type" was not found in protobuf')
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
1314
|
return obj
|
|
1400
1315
|
})
|
|
1401
1316
|
}
|
|
@@ -1426,47 +1341,45 @@ export namespace PSMessage {
|
|
|
1426
1341
|
|
|
1427
1342
|
export const codec = (): Codec<PSMessage> => {
|
|
1428
1343
|
if (_codec == null) {
|
|
1429
|
-
_codec = message<PSMessage>((obj,
|
|
1344
|
+
_codec = message<PSMessage>((obj, w, opts = {}) => {
|
|
1430
1345
|
if (opts.lengthDelimited !== false) {
|
|
1431
|
-
|
|
1346
|
+
w.fork()
|
|
1432
1347
|
}
|
|
1433
1348
|
|
|
1434
1349
|
if (obj.from != null) {
|
|
1435
|
-
|
|
1436
|
-
|
|
1350
|
+
w.uint32(10)
|
|
1351
|
+
w.bytes(obj.from)
|
|
1437
1352
|
}
|
|
1438
1353
|
|
|
1439
1354
|
if (obj.data != null) {
|
|
1440
|
-
|
|
1441
|
-
|
|
1355
|
+
w.uint32(18)
|
|
1356
|
+
w.bytes(obj.data)
|
|
1442
1357
|
}
|
|
1443
1358
|
|
|
1444
1359
|
if (obj.seqno != null) {
|
|
1445
|
-
|
|
1446
|
-
|
|
1360
|
+
w.uint32(26)
|
|
1361
|
+
w.bytes(obj.seqno)
|
|
1447
1362
|
}
|
|
1448
1363
|
|
|
1449
1364
|
if (obj.topicIDs != null) {
|
|
1450
1365
|
for (const value of obj.topicIDs) {
|
|
1451
|
-
|
|
1452
|
-
|
|
1366
|
+
w.uint32(34)
|
|
1367
|
+
w.string(value)
|
|
1453
1368
|
}
|
|
1454
|
-
} else {
|
|
1455
|
-
throw new Error('Protocol error: required field "topicIDs" was not found in object')
|
|
1456
1369
|
}
|
|
1457
1370
|
|
|
1458
1371
|
if (obj.signature != null) {
|
|
1459
|
-
|
|
1460
|
-
|
|
1372
|
+
w.uint32(42)
|
|
1373
|
+
w.bytes(obj.signature)
|
|
1461
1374
|
}
|
|
1462
1375
|
|
|
1463
1376
|
if (obj.key != null) {
|
|
1464
|
-
|
|
1465
|
-
|
|
1377
|
+
w.uint32(50)
|
|
1378
|
+
w.bytes(obj.key)
|
|
1466
1379
|
}
|
|
1467
1380
|
|
|
1468
1381
|
if (opts.lengthDelimited !== false) {
|
|
1469
|
-
|
|
1382
|
+
w.ldelim()
|
|
1470
1383
|
}
|
|
1471
1384
|
}, (reader, length) => {
|
|
1472
1385
|
const obj: any = {
|
|
@@ -1529,31 +1442,27 @@ export namespace PSResponse {
|
|
|
1529
1442
|
|
|
1530
1443
|
export const codec = (): Codec<PSResponse> => {
|
|
1531
1444
|
if (_codec == null) {
|
|
1532
|
-
_codec = message<PSResponse>((obj,
|
|
1445
|
+
_codec = message<PSResponse>((obj, w, opts = {}) => {
|
|
1533
1446
|
if (opts.lengthDelimited !== false) {
|
|
1534
|
-
|
|
1447
|
+
w.fork()
|
|
1535
1448
|
}
|
|
1536
1449
|
|
|
1537
1450
|
if (obj.topics != null) {
|
|
1538
1451
|
for (const value of obj.topics) {
|
|
1539
|
-
|
|
1540
|
-
|
|
1452
|
+
w.uint32(10)
|
|
1453
|
+
w.string(value)
|
|
1541
1454
|
}
|
|
1542
|
-
} else {
|
|
1543
|
-
throw new Error('Protocol error: required field "topics" was not found in object')
|
|
1544
1455
|
}
|
|
1545
1456
|
|
|
1546
1457
|
if (obj.peerIDs != null) {
|
|
1547
1458
|
for (const value of obj.peerIDs) {
|
|
1548
|
-
|
|
1549
|
-
|
|
1459
|
+
w.uint32(18)
|
|
1460
|
+
w.bytes(value)
|
|
1550
1461
|
}
|
|
1551
|
-
} else {
|
|
1552
|
-
throw new Error('Protocol error: required field "peerIDs" was not found in object')
|
|
1553
1462
|
}
|
|
1554
1463
|
|
|
1555
1464
|
if (opts.lengthDelimited !== false) {
|
|
1556
|
-
|
|
1465
|
+
w.ldelim()
|
|
1557
1466
|
}
|
|
1558
1467
|
}, (reader, length) => {
|
|
1559
1468
|
const obj: any = {
|
|
@@ -1596,7 +1505,7 @@ export namespace PSResponse {
|
|
|
1596
1505
|
}
|
|
1597
1506
|
|
|
1598
1507
|
export interface PeerstoreRequest {
|
|
1599
|
-
type
|
|
1508
|
+
type?: PeerstoreRequest.Type
|
|
1600
1509
|
id?: Uint8Array
|
|
1601
1510
|
protos: string[]
|
|
1602
1511
|
}
|
|
@@ -1624,38 +1533,33 @@ export namespace PeerstoreRequest {
|
|
|
1624
1533
|
|
|
1625
1534
|
export const codec = (): Codec<PeerstoreRequest> => {
|
|
1626
1535
|
if (_codec == null) {
|
|
1627
|
-
_codec = message<PeerstoreRequest>((obj,
|
|
1536
|
+
_codec = message<PeerstoreRequest>((obj, w, opts = {}) => {
|
|
1628
1537
|
if (opts.lengthDelimited !== false) {
|
|
1629
|
-
|
|
1538
|
+
w.fork()
|
|
1630
1539
|
}
|
|
1631
1540
|
|
|
1632
1541
|
if (obj.type != null) {
|
|
1633
|
-
|
|
1634
|
-
PeerstoreRequest.Type.codec().encode(obj.type,
|
|
1635
|
-
} else {
|
|
1636
|
-
throw new Error('Protocol error: required field "type" was not found in object')
|
|
1542
|
+
w.uint32(8)
|
|
1543
|
+
PeerstoreRequest.Type.codec().encode(obj.type, w)
|
|
1637
1544
|
}
|
|
1638
1545
|
|
|
1639
1546
|
if (obj.id != null) {
|
|
1640
|
-
|
|
1641
|
-
|
|
1547
|
+
w.uint32(18)
|
|
1548
|
+
w.bytes(obj.id)
|
|
1642
1549
|
}
|
|
1643
1550
|
|
|
1644
1551
|
if (obj.protos != null) {
|
|
1645
1552
|
for (const value of obj.protos) {
|
|
1646
|
-
|
|
1647
|
-
|
|
1553
|
+
w.uint32(26)
|
|
1554
|
+
w.string(value)
|
|
1648
1555
|
}
|
|
1649
|
-
} else {
|
|
1650
|
-
throw new Error('Protocol error: required field "protos" was not found in object')
|
|
1651
1556
|
}
|
|
1652
1557
|
|
|
1653
1558
|
if (opts.lengthDelimited !== false) {
|
|
1654
|
-
|
|
1559
|
+
w.ldelim()
|
|
1655
1560
|
}
|
|
1656
1561
|
}, (reader, length) => {
|
|
1657
1562
|
const obj: any = {
|
|
1658
|
-
type: Type.UNSPECIFIED,
|
|
1659
1563
|
protos: []
|
|
1660
1564
|
}
|
|
1661
1565
|
|
|
@@ -1680,10 +1584,6 @@ export namespace PeerstoreRequest {
|
|
|
1680
1584
|
}
|
|
1681
1585
|
}
|
|
1682
1586
|
|
|
1683
|
-
if (obj.type == null) {
|
|
1684
|
-
throw new Error('Protocol error: value for required field "type" was not found in protobuf')
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
1587
|
return obj
|
|
1688
1588
|
})
|
|
1689
1589
|
}
|
|
@@ -1710,27 +1610,27 @@ export namespace PeerstoreResponse {
|
|
|
1710
1610
|
|
|
1711
1611
|
export const codec = (): Codec<PeerstoreResponse> => {
|
|
1712
1612
|
if (_codec == null) {
|
|
1713
|
-
_codec = message<PeerstoreResponse>((obj,
|
|
1613
|
+
_codec = message<PeerstoreResponse>((obj, w, opts = {}) => {
|
|
1714
1614
|
if (opts.lengthDelimited !== false) {
|
|
1715
|
-
|
|
1615
|
+
w.fork()
|
|
1716
1616
|
}
|
|
1717
1617
|
|
|
1718
1618
|
if (obj.peer != null) {
|
|
1719
|
-
|
|
1720
|
-
PeerInfo.codec().encode(obj.peer,
|
|
1619
|
+
w.uint32(10)
|
|
1620
|
+
PeerInfo.codec().encode(obj.peer, w, {
|
|
1621
|
+
writeDefaults: false
|
|
1622
|
+
})
|
|
1721
1623
|
}
|
|
1722
1624
|
|
|
1723
1625
|
if (obj.protos != null) {
|
|
1724
1626
|
for (const value of obj.protos) {
|
|
1725
|
-
|
|
1726
|
-
|
|
1627
|
+
w.uint32(18)
|
|
1628
|
+
w.string(value)
|
|
1727
1629
|
}
|
|
1728
|
-
} else {
|
|
1729
|
-
throw new Error('Protocol error: required field "protos" was not found in object')
|
|
1730
1630
|
}
|
|
1731
1631
|
|
|
1732
1632
|
if (opts.lengthDelimited !== false) {
|
|
1733
|
-
|
|
1633
|
+
w.ldelim()
|
|
1734
1634
|
}
|
|
1735
1635
|
}, (reader, length) => {
|
|
1736
1636
|
const obj: any = {
|