@helia/bitswap 4.0.17 → 4.0.18-d4962087
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/pb/message.d.ts +37 -12
- package/dist/src/pb/message.d.ts.map +1 -1
- package/dist/src/pb/message.js +80 -80
- package/dist/src/pb/message.js.map +1 -1
- package/package.json +6 -6
- package/src/pb/message.ts +132 -102
- package/dist/typedoc-urls.json +0 -29
package/src/pb/message.ts
CHANGED
|
@@ -14,7 +14,7 @@ enum __WantTypeValues {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export namespace WantType {
|
|
17
|
-
export const codec = (): Codec<WantType> => {
|
|
17
|
+
export const codec = (): Codec<WantType, WantType> => {
|
|
18
18
|
return enumeration<WantType>(__WantTypeValues)
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -27,12 +27,20 @@ export interface WantlistEntry {
|
|
|
27
27
|
sendDontHave?: boolean
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export interface WantlistEntryInput {
|
|
31
|
+
cid?: Uint8Array
|
|
32
|
+
priority?: number
|
|
33
|
+
cancel?: boolean
|
|
34
|
+
wantType?: WantType
|
|
35
|
+
sendDontHave?: boolean
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
export namespace WantlistEntry {
|
|
31
|
-
let _codec: Codec<WantlistEntry>
|
|
39
|
+
let _codec: Codec<WantlistEntry, WantlistEntryInput>
|
|
32
40
|
|
|
33
|
-
export const codec = (): Codec<WantlistEntry> => {
|
|
41
|
+
export const codec = (): Codec<WantlistEntry, WantlistEntryInput> => {
|
|
34
42
|
if (_codec == null) {
|
|
35
|
-
_codec = message<WantlistEntry>((obj, w, opts = {}) => {
|
|
43
|
+
_codec = message<WantlistEntry, WantlistEntryInput>((obj, w, opts = {}) => {
|
|
36
44
|
if (opts.lengthDelimited !== false) {
|
|
37
45
|
w.fork()
|
|
38
46
|
}
|
|
@@ -65,48 +73,48 @@ export namespace WantlistEntry {
|
|
|
65
73
|
if (opts.lengthDelimited !== false) {
|
|
66
74
|
w.ldelim()
|
|
67
75
|
}
|
|
68
|
-
}, (
|
|
76
|
+
}, (r, length) => {
|
|
69
77
|
const obj: any = {
|
|
70
78
|
cid: uint8ArrayAlloc(0),
|
|
71
79
|
priority: 0
|
|
72
80
|
}
|
|
73
81
|
|
|
74
|
-
const end = length == null ?
|
|
82
|
+
const end = length == null ? r.len : r.pos + length
|
|
75
83
|
|
|
76
|
-
while (
|
|
77
|
-
const tag =
|
|
84
|
+
while (r.pos < end) {
|
|
85
|
+
const tag = r.uint32()
|
|
78
86
|
|
|
79
87
|
switch (tag >>> 3) {
|
|
80
88
|
case 1: {
|
|
81
|
-
obj.cid =
|
|
89
|
+
obj.cid = r.bytes()
|
|
82
90
|
break
|
|
83
91
|
}
|
|
84
92
|
case 2: {
|
|
85
|
-
obj.priority =
|
|
93
|
+
obj.priority = r.int32()
|
|
86
94
|
break
|
|
87
95
|
}
|
|
88
96
|
case 3: {
|
|
89
|
-
obj.cancel =
|
|
97
|
+
obj.cancel = r.bool()
|
|
90
98
|
break
|
|
91
99
|
}
|
|
92
100
|
case 4: {
|
|
93
|
-
obj.wantType = WantType.codec().decode(
|
|
101
|
+
obj.wantType = WantType.codec().decode(r)
|
|
94
102
|
break
|
|
95
103
|
}
|
|
96
104
|
case 5: {
|
|
97
|
-
obj.sendDontHave =
|
|
105
|
+
obj.sendDontHave = r.bool()
|
|
98
106
|
break
|
|
99
107
|
}
|
|
100
108
|
default: {
|
|
101
|
-
|
|
109
|
+
r.skipType(tag & 7)
|
|
102
110
|
break
|
|
103
111
|
}
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
return obj
|
|
108
|
-
}, function * (
|
|
109
|
-
const end = length == null ?
|
|
116
|
+
}, function * (r, length, prefix) {
|
|
117
|
+
const end = length == null ? r.len : r.pos + length
|
|
110
118
|
|
|
111
119
|
if (prefix !== '.') {
|
|
112
120
|
yield {
|
|
@@ -116,47 +124,47 @@ export namespace WantlistEntry {
|
|
|
116
124
|
}
|
|
117
125
|
}
|
|
118
126
|
|
|
119
|
-
while (
|
|
120
|
-
const tag =
|
|
127
|
+
while (r.pos < end) {
|
|
128
|
+
const tag = r.uint32()
|
|
121
129
|
|
|
122
130
|
switch (tag >>> 3) {
|
|
123
131
|
case 1: {
|
|
124
132
|
yield {
|
|
125
133
|
field: `${prefix}cid`,
|
|
126
|
-
value:
|
|
134
|
+
value: r.bytes()
|
|
127
135
|
}
|
|
128
136
|
break
|
|
129
137
|
}
|
|
130
138
|
case 2: {
|
|
131
139
|
yield {
|
|
132
140
|
field: `${prefix}priority`,
|
|
133
|
-
value:
|
|
141
|
+
value: r.int32()
|
|
134
142
|
}
|
|
135
143
|
break
|
|
136
144
|
}
|
|
137
145
|
case 3: {
|
|
138
146
|
yield {
|
|
139
147
|
field: `${prefix}cancel`,
|
|
140
|
-
value:
|
|
148
|
+
value: r.bool()
|
|
141
149
|
}
|
|
142
150
|
break
|
|
143
151
|
}
|
|
144
152
|
case 4: {
|
|
145
153
|
yield {
|
|
146
154
|
field: `${prefix}wantType`,
|
|
147
|
-
value: WantType.codec().decode(
|
|
155
|
+
value: WantType.codec().decode(r)
|
|
148
156
|
}
|
|
149
157
|
break
|
|
150
158
|
}
|
|
151
159
|
case 5: {
|
|
152
160
|
yield {
|
|
153
161
|
field: `${prefix}sendDontHave`,
|
|
154
|
-
value:
|
|
162
|
+
value: r.bool()
|
|
155
163
|
}
|
|
156
164
|
break
|
|
157
165
|
}
|
|
158
166
|
default: {
|
|
159
|
-
|
|
167
|
+
r.skipType(tag & 7)
|
|
160
168
|
break
|
|
161
169
|
}
|
|
162
170
|
}
|
|
@@ -200,7 +208,7 @@ export namespace WantlistEntry {
|
|
|
200
208
|
value: boolean
|
|
201
209
|
}
|
|
202
210
|
|
|
203
|
-
export function encode (obj:
|
|
211
|
+
export function encode (obj: WantlistEntryInput): Uint8Array<ArrayBuffer> {
|
|
204
212
|
return encodeMessage(obj, WantlistEntry.codec())
|
|
205
213
|
}
|
|
206
214
|
|
|
@@ -218,12 +226,17 @@ export interface Wantlist {
|
|
|
218
226
|
full?: boolean
|
|
219
227
|
}
|
|
220
228
|
|
|
229
|
+
export interface WantlistInput {
|
|
230
|
+
entries?: WantlistEntryInput[]
|
|
231
|
+
full?: boolean
|
|
232
|
+
}
|
|
233
|
+
|
|
221
234
|
export namespace Wantlist {
|
|
222
|
-
let _codec: Codec<Wantlist>
|
|
235
|
+
let _codec: Codec<Wantlist, WantlistInput>
|
|
223
236
|
|
|
224
|
-
export const codec = (): Codec<Wantlist> => {
|
|
237
|
+
export const codec = (): Codec<Wantlist, WantlistInput> => {
|
|
225
238
|
if (_codec == null) {
|
|
226
|
-
_codec = message<Wantlist>((obj, w, opts = {}) => {
|
|
239
|
+
_codec = message<Wantlist, WantlistInput>((obj, w, opts = {}) => {
|
|
227
240
|
if (opts.lengthDelimited !== false) {
|
|
228
241
|
w.fork()
|
|
229
242
|
}
|
|
@@ -243,15 +256,15 @@ export namespace Wantlist {
|
|
|
243
256
|
if (opts.lengthDelimited !== false) {
|
|
244
257
|
w.ldelim()
|
|
245
258
|
}
|
|
246
|
-
}, (
|
|
259
|
+
}, (r, length, opts = {}) => {
|
|
247
260
|
const obj: any = {
|
|
248
261
|
entries: []
|
|
249
262
|
}
|
|
250
263
|
|
|
251
|
-
const end = length == null ?
|
|
264
|
+
const end = length == null ? r.len : r.pos + length
|
|
252
265
|
|
|
253
|
-
while (
|
|
254
|
-
const tag =
|
|
266
|
+
while (r.pos < end) {
|
|
267
|
+
const tag = r.uint32()
|
|
255
268
|
|
|
256
269
|
switch (tag >>> 3) {
|
|
257
270
|
case 1: {
|
|
@@ -259,29 +272,29 @@ export namespace Wantlist {
|
|
|
259
272
|
throw new MaxLengthError('Decode error - repeated field "entries" had too many elements')
|
|
260
273
|
}
|
|
261
274
|
|
|
262
|
-
obj.entries.push(WantlistEntry.codec().decode(
|
|
275
|
+
obj.entries.push(WantlistEntry.codec().decode(r, r.uint32(), {
|
|
263
276
|
limits: opts.limits?.entries$
|
|
264
277
|
}))
|
|
265
278
|
break
|
|
266
279
|
}
|
|
267
280
|
case 2: {
|
|
268
|
-
obj.full =
|
|
281
|
+
obj.full = r.bool()
|
|
269
282
|
break
|
|
270
283
|
}
|
|
271
284
|
default: {
|
|
272
|
-
|
|
285
|
+
r.skipType(tag & 7)
|
|
273
286
|
break
|
|
274
287
|
}
|
|
275
288
|
}
|
|
276
289
|
}
|
|
277
290
|
|
|
278
291
|
return obj
|
|
279
|
-
}, function * (
|
|
292
|
+
}, function * (r, length, prefix, opts = {}) {
|
|
280
293
|
const obj = {
|
|
281
294
|
entries: 0
|
|
282
295
|
}
|
|
283
296
|
|
|
284
|
-
const end = length == null ?
|
|
297
|
+
const end = length == null ? r.len : r.pos + length
|
|
285
298
|
|
|
286
299
|
if (prefix !== '.') {
|
|
287
300
|
yield {
|
|
@@ -291,8 +304,8 @@ export namespace Wantlist {
|
|
|
291
304
|
}
|
|
292
305
|
}
|
|
293
306
|
|
|
294
|
-
while (
|
|
295
|
-
const tag =
|
|
307
|
+
while (r.pos < end) {
|
|
308
|
+
const tag = r.uint32()
|
|
296
309
|
|
|
297
310
|
switch (tag >>> 3) {
|
|
298
311
|
case 1: {
|
|
@@ -300,7 +313,7 @@ export namespace Wantlist {
|
|
|
300
313
|
throw new MaxLengthError('Streaming decode error - repeated field "entries" had too many elements')
|
|
301
314
|
}
|
|
302
315
|
|
|
303
|
-
for (const evt of WantlistEntry.codec().stream(
|
|
316
|
+
for (const evt of WantlistEntry.codec().stream(r, r.uint32(), `${prefix}entries[].`, {
|
|
304
317
|
limits: opts.limits?.entries$
|
|
305
318
|
})) {
|
|
306
319
|
yield {
|
|
@@ -316,12 +329,12 @@ export namespace Wantlist {
|
|
|
316
329
|
case 2: {
|
|
317
330
|
yield {
|
|
318
331
|
field: `${prefix}full`,
|
|
319
|
-
value:
|
|
332
|
+
value: r.bool()
|
|
320
333
|
}
|
|
321
334
|
break
|
|
322
335
|
}
|
|
323
336
|
default: {
|
|
324
|
-
|
|
337
|
+
r.skipType(tag & 7)
|
|
325
338
|
break
|
|
326
339
|
}
|
|
327
340
|
}
|
|
@@ -389,7 +402,7 @@ export namespace Wantlist {
|
|
|
389
402
|
value: boolean
|
|
390
403
|
}
|
|
391
404
|
|
|
392
|
-
export function encode (obj:
|
|
405
|
+
export function encode (obj: WantlistInput): Uint8Array<ArrayBuffer> {
|
|
393
406
|
return encodeMessage(obj, Wantlist.codec())
|
|
394
407
|
}
|
|
395
408
|
|
|
@@ -407,12 +420,17 @@ export interface Block {
|
|
|
407
420
|
data: Uint8Array<ArrayBuffer>
|
|
408
421
|
}
|
|
409
422
|
|
|
423
|
+
export interface BlockInput {
|
|
424
|
+
prefix?: Uint8Array
|
|
425
|
+
data?: Uint8Array
|
|
426
|
+
}
|
|
427
|
+
|
|
410
428
|
export namespace Block {
|
|
411
|
-
let _codec: Codec<Block>
|
|
429
|
+
let _codec: Codec<Block, BlockInput>
|
|
412
430
|
|
|
413
|
-
export const codec = (): Codec<Block> => {
|
|
431
|
+
export const codec = (): Codec<Block, BlockInput> => {
|
|
414
432
|
if (_codec == null) {
|
|
415
|
-
_codec = message<Block>((obj, w, opts = {}) => {
|
|
433
|
+
_codec = message<Block, BlockInput>((obj, w, opts = {}) => {
|
|
416
434
|
if (opts.lengthDelimited !== false) {
|
|
417
435
|
w.fork()
|
|
418
436
|
}
|
|
@@ -430,36 +448,36 @@ export namespace Block {
|
|
|
430
448
|
if (opts.lengthDelimited !== false) {
|
|
431
449
|
w.ldelim()
|
|
432
450
|
}
|
|
433
|
-
}, (
|
|
451
|
+
}, (r, length) => {
|
|
434
452
|
const obj: any = {
|
|
435
453
|
prefix: uint8ArrayAlloc(0),
|
|
436
454
|
data: uint8ArrayAlloc(0)
|
|
437
455
|
}
|
|
438
456
|
|
|
439
|
-
const end = length == null ?
|
|
457
|
+
const end = length == null ? r.len : r.pos + length
|
|
440
458
|
|
|
441
|
-
while (
|
|
442
|
-
const tag =
|
|
459
|
+
while (r.pos < end) {
|
|
460
|
+
const tag = r.uint32()
|
|
443
461
|
|
|
444
462
|
switch (tag >>> 3) {
|
|
445
463
|
case 1: {
|
|
446
|
-
obj.prefix =
|
|
464
|
+
obj.prefix = r.bytes()
|
|
447
465
|
break
|
|
448
466
|
}
|
|
449
467
|
case 2: {
|
|
450
|
-
obj.data =
|
|
468
|
+
obj.data = r.bytes()
|
|
451
469
|
break
|
|
452
470
|
}
|
|
453
471
|
default: {
|
|
454
|
-
|
|
472
|
+
r.skipType(tag & 7)
|
|
455
473
|
break
|
|
456
474
|
}
|
|
457
475
|
}
|
|
458
476
|
}
|
|
459
477
|
|
|
460
478
|
return obj
|
|
461
|
-
}, function * (
|
|
462
|
-
const end = length == null ?
|
|
479
|
+
}, function * (r, length, prefix) {
|
|
480
|
+
const end = length == null ? r.len : r.pos + length
|
|
463
481
|
|
|
464
482
|
if (prefix !== '.') {
|
|
465
483
|
yield {
|
|
@@ -469,26 +487,26 @@ export namespace Block {
|
|
|
469
487
|
}
|
|
470
488
|
}
|
|
471
489
|
|
|
472
|
-
while (
|
|
473
|
-
const tag =
|
|
490
|
+
while (r.pos < end) {
|
|
491
|
+
const tag = r.uint32()
|
|
474
492
|
|
|
475
493
|
switch (tag >>> 3) {
|
|
476
494
|
case 1: {
|
|
477
495
|
yield {
|
|
478
496
|
field: `${prefix}prefix`,
|
|
479
|
-
value:
|
|
497
|
+
value: r.bytes()
|
|
480
498
|
}
|
|
481
499
|
break
|
|
482
500
|
}
|
|
483
501
|
case 2: {
|
|
484
502
|
yield {
|
|
485
503
|
field: `${prefix}data`,
|
|
486
|
-
value:
|
|
504
|
+
value: r.bytes()
|
|
487
505
|
}
|
|
488
506
|
break
|
|
489
507
|
}
|
|
490
508
|
default: {
|
|
491
|
-
|
|
509
|
+
r.skipType(tag & 7)
|
|
492
510
|
break
|
|
493
511
|
}
|
|
494
512
|
}
|
|
@@ -517,7 +535,7 @@ export namespace Block {
|
|
|
517
535
|
value: Uint8Array<ArrayBuffer>
|
|
518
536
|
}
|
|
519
537
|
|
|
520
|
-
export function encode (obj:
|
|
538
|
+
export function encode (obj: BlockInput): Uint8Array<ArrayBuffer> {
|
|
521
539
|
return encodeMessage(obj, Block.codec())
|
|
522
540
|
}
|
|
523
541
|
|
|
@@ -541,7 +559,7 @@ enum __BlockPresenceTypeValues {
|
|
|
541
559
|
}
|
|
542
560
|
|
|
543
561
|
export namespace BlockPresenceType {
|
|
544
|
-
export const codec = (): Codec<BlockPresenceType> => {
|
|
562
|
+
export const codec = (): Codec<BlockPresenceType, BlockPresenceType> => {
|
|
545
563
|
return enumeration<BlockPresenceType>(__BlockPresenceTypeValues)
|
|
546
564
|
}
|
|
547
565
|
}
|
|
@@ -551,12 +569,17 @@ export interface BlockPresence {
|
|
|
551
569
|
type: BlockPresenceType
|
|
552
570
|
}
|
|
553
571
|
|
|
572
|
+
export interface BlockPresenceInput {
|
|
573
|
+
cid?: Uint8Array
|
|
574
|
+
type?: BlockPresenceType
|
|
575
|
+
}
|
|
576
|
+
|
|
554
577
|
export namespace BlockPresence {
|
|
555
|
-
let _codec: Codec<BlockPresence>
|
|
578
|
+
let _codec: Codec<BlockPresence, BlockPresenceInput>
|
|
556
579
|
|
|
557
|
-
export const codec = (): Codec<BlockPresence> => {
|
|
580
|
+
export const codec = (): Codec<BlockPresence, BlockPresenceInput> => {
|
|
558
581
|
if (_codec == null) {
|
|
559
|
-
_codec = message<BlockPresence>((obj, w, opts = {}) => {
|
|
582
|
+
_codec = message<BlockPresence, BlockPresenceInput>((obj, w, opts = {}) => {
|
|
560
583
|
if (opts.lengthDelimited !== false) {
|
|
561
584
|
w.fork()
|
|
562
585
|
}
|
|
@@ -574,36 +597,36 @@ export namespace BlockPresence {
|
|
|
574
597
|
if (opts.lengthDelimited !== false) {
|
|
575
598
|
w.ldelim()
|
|
576
599
|
}
|
|
577
|
-
}, (
|
|
600
|
+
}, (r, length) => {
|
|
578
601
|
const obj: any = {
|
|
579
602
|
cid: uint8ArrayAlloc(0),
|
|
580
603
|
type: BlockPresenceType.HaveBlock
|
|
581
604
|
}
|
|
582
605
|
|
|
583
|
-
const end = length == null ?
|
|
606
|
+
const end = length == null ? r.len : r.pos + length
|
|
584
607
|
|
|
585
|
-
while (
|
|
586
|
-
const tag =
|
|
608
|
+
while (r.pos < end) {
|
|
609
|
+
const tag = r.uint32()
|
|
587
610
|
|
|
588
611
|
switch (tag >>> 3) {
|
|
589
612
|
case 1: {
|
|
590
|
-
obj.cid =
|
|
613
|
+
obj.cid = r.bytes()
|
|
591
614
|
break
|
|
592
615
|
}
|
|
593
616
|
case 2: {
|
|
594
|
-
obj.type = BlockPresenceType.codec().decode(
|
|
617
|
+
obj.type = BlockPresenceType.codec().decode(r)
|
|
595
618
|
break
|
|
596
619
|
}
|
|
597
620
|
default: {
|
|
598
|
-
|
|
621
|
+
r.skipType(tag & 7)
|
|
599
622
|
break
|
|
600
623
|
}
|
|
601
624
|
}
|
|
602
625
|
}
|
|
603
626
|
|
|
604
627
|
return obj
|
|
605
|
-
}, function * (
|
|
606
|
-
const end = length == null ?
|
|
628
|
+
}, function * (r, length, prefix) {
|
|
629
|
+
const end = length == null ? r.len : r.pos + length
|
|
607
630
|
|
|
608
631
|
if (prefix !== '.') {
|
|
609
632
|
yield {
|
|
@@ -613,26 +636,26 @@ export namespace BlockPresence {
|
|
|
613
636
|
}
|
|
614
637
|
}
|
|
615
638
|
|
|
616
|
-
while (
|
|
617
|
-
const tag =
|
|
639
|
+
while (r.pos < end) {
|
|
640
|
+
const tag = r.uint32()
|
|
618
641
|
|
|
619
642
|
switch (tag >>> 3) {
|
|
620
643
|
case 1: {
|
|
621
644
|
yield {
|
|
622
645
|
field: `${prefix}cid`,
|
|
623
|
-
value:
|
|
646
|
+
value: r.bytes()
|
|
624
647
|
}
|
|
625
648
|
break
|
|
626
649
|
}
|
|
627
650
|
case 2: {
|
|
628
651
|
yield {
|
|
629
652
|
field: `${prefix}type`,
|
|
630
|
-
value: BlockPresenceType.codec().decode(
|
|
653
|
+
value: BlockPresenceType.codec().decode(r)
|
|
631
654
|
}
|
|
632
655
|
break
|
|
633
656
|
}
|
|
634
657
|
default: {
|
|
635
|
-
|
|
658
|
+
r.skipType(tag & 7)
|
|
636
659
|
break
|
|
637
660
|
}
|
|
638
661
|
}
|
|
@@ -661,7 +684,7 @@ export namespace BlockPresence {
|
|
|
661
684
|
value: BlockPresenceType
|
|
662
685
|
}
|
|
663
686
|
|
|
664
|
-
export function encode (obj:
|
|
687
|
+
export function encode (obj: BlockPresenceInput): Uint8Array<ArrayBuffer> {
|
|
665
688
|
return encodeMessage(obj, BlockPresence.codec())
|
|
666
689
|
}
|
|
667
690
|
|
|
@@ -681,12 +704,19 @@ export interface BitswapMessage {
|
|
|
681
704
|
pendingBytes: number
|
|
682
705
|
}
|
|
683
706
|
|
|
707
|
+
export interface BitswapMessageInput {
|
|
708
|
+
wantlist?: WantlistInput
|
|
709
|
+
blocks?: BlockInput[]
|
|
710
|
+
blockPresences?: BlockPresenceInput[]
|
|
711
|
+
pendingBytes?: number
|
|
712
|
+
}
|
|
713
|
+
|
|
684
714
|
export namespace BitswapMessage {
|
|
685
|
-
let _codec: Codec<BitswapMessage>
|
|
715
|
+
let _codec: Codec<BitswapMessage, BitswapMessageInput>
|
|
686
716
|
|
|
687
|
-
export const codec = (): Codec<BitswapMessage> => {
|
|
717
|
+
export const codec = (): Codec<BitswapMessage, BitswapMessageInput> => {
|
|
688
718
|
if (_codec == null) {
|
|
689
|
-
_codec = message<BitswapMessage>((obj, w, opts = {}) => {
|
|
719
|
+
_codec = message<BitswapMessage, BitswapMessageInput>((obj, w, opts = {}) => {
|
|
690
720
|
if (opts.lengthDelimited !== false) {
|
|
691
721
|
w.fork()
|
|
692
722
|
}
|
|
@@ -718,21 +748,21 @@ export namespace BitswapMessage {
|
|
|
718
748
|
if (opts.lengthDelimited !== false) {
|
|
719
749
|
w.ldelim()
|
|
720
750
|
}
|
|
721
|
-
}, (
|
|
751
|
+
}, (r, length, opts = {}) => {
|
|
722
752
|
const obj: any = {
|
|
723
753
|
blocks: [],
|
|
724
754
|
blockPresences: [],
|
|
725
755
|
pendingBytes: 0
|
|
726
756
|
}
|
|
727
757
|
|
|
728
|
-
const end = length == null ?
|
|
758
|
+
const end = length == null ? r.len : r.pos + length
|
|
729
759
|
|
|
730
|
-
while (
|
|
731
|
-
const tag =
|
|
760
|
+
while (r.pos < end) {
|
|
761
|
+
const tag = r.uint32()
|
|
732
762
|
|
|
733
763
|
switch (tag >>> 3) {
|
|
734
764
|
case 1: {
|
|
735
|
-
obj.wantlist = Wantlist.codec().decode(
|
|
765
|
+
obj.wantlist = Wantlist.codec().decode(r, r.uint32(), {
|
|
736
766
|
limits: opts.limits?.wantlist
|
|
737
767
|
})
|
|
738
768
|
break
|
|
@@ -742,7 +772,7 @@ export namespace BitswapMessage {
|
|
|
742
772
|
throw new MaxLengthError('Decode error - repeated field "blocks" had too many elements')
|
|
743
773
|
}
|
|
744
774
|
|
|
745
|
-
obj.blocks.push(Block.codec().decode(
|
|
775
|
+
obj.blocks.push(Block.codec().decode(r, r.uint32(), {
|
|
746
776
|
limits: opts.limits?.blocks$
|
|
747
777
|
}))
|
|
748
778
|
break
|
|
@@ -752,30 +782,30 @@ export namespace BitswapMessage {
|
|
|
752
782
|
throw new MaxLengthError('Decode error - repeated field "blockPresences" had too many elements')
|
|
753
783
|
}
|
|
754
784
|
|
|
755
|
-
obj.blockPresences.push(BlockPresence.codec().decode(
|
|
785
|
+
obj.blockPresences.push(BlockPresence.codec().decode(r, r.uint32(), {
|
|
756
786
|
limits: opts.limits?.blockPresences$
|
|
757
787
|
}))
|
|
758
788
|
break
|
|
759
789
|
}
|
|
760
790
|
case 5: {
|
|
761
|
-
obj.pendingBytes =
|
|
791
|
+
obj.pendingBytes = r.int32()
|
|
762
792
|
break
|
|
763
793
|
}
|
|
764
794
|
default: {
|
|
765
|
-
|
|
795
|
+
r.skipType(tag & 7)
|
|
766
796
|
break
|
|
767
797
|
}
|
|
768
798
|
}
|
|
769
799
|
}
|
|
770
800
|
|
|
771
801
|
return obj
|
|
772
|
-
}, function * (
|
|
802
|
+
}, function * (r, length, prefix, opts = {}) {
|
|
773
803
|
const obj = {
|
|
774
804
|
blocks: 0,
|
|
775
805
|
blockPresences: 0
|
|
776
806
|
}
|
|
777
807
|
|
|
778
|
-
const end = length == null ?
|
|
808
|
+
const end = length == null ? r.len : r.pos + length
|
|
779
809
|
|
|
780
810
|
if (prefix !== '.') {
|
|
781
811
|
yield {
|
|
@@ -785,12 +815,12 @@ export namespace BitswapMessage {
|
|
|
785
815
|
}
|
|
786
816
|
}
|
|
787
817
|
|
|
788
|
-
while (
|
|
789
|
-
const tag =
|
|
818
|
+
while (r.pos < end) {
|
|
819
|
+
const tag = r.uint32()
|
|
790
820
|
|
|
791
821
|
switch (tag >>> 3) {
|
|
792
822
|
case 1: {
|
|
793
|
-
yield * Wantlist.codec().stream(
|
|
823
|
+
yield * Wantlist.codec().stream(r, r.uint32(), `${prefix}wantlist.`, {
|
|
794
824
|
limits: opts.limits?.wantlist
|
|
795
825
|
})
|
|
796
826
|
|
|
@@ -801,7 +831,7 @@ export namespace BitswapMessage {
|
|
|
801
831
|
throw new MaxLengthError('Streaming decode error - repeated field "blocks" had too many elements')
|
|
802
832
|
}
|
|
803
833
|
|
|
804
|
-
for (const evt of Block.codec().stream(
|
|
834
|
+
for (const evt of Block.codec().stream(r, r.uint32(), `${prefix}blocks[].`, {
|
|
805
835
|
limits: opts.limits?.blocks$
|
|
806
836
|
})) {
|
|
807
837
|
yield {
|
|
@@ -819,7 +849,7 @@ export namespace BitswapMessage {
|
|
|
819
849
|
throw new MaxLengthError('Streaming decode error - repeated field "blockPresences" had too many elements')
|
|
820
850
|
}
|
|
821
851
|
|
|
822
|
-
for (const evt of BlockPresence.codec().stream(
|
|
852
|
+
for (const evt of BlockPresence.codec().stream(r, r.uint32(), `${prefix}blockPresences[].`, {
|
|
823
853
|
limits: opts.limits?.blockPresences$
|
|
824
854
|
})) {
|
|
825
855
|
yield {
|
|
@@ -835,12 +865,12 @@ export namespace BitswapMessage {
|
|
|
835
865
|
case 5: {
|
|
836
866
|
yield {
|
|
837
867
|
field: `${prefix}pendingBytes`,
|
|
838
|
-
value:
|
|
868
|
+
value: r.int32()
|
|
839
869
|
}
|
|
840
870
|
break
|
|
841
871
|
}
|
|
842
872
|
default: {
|
|
843
|
-
|
|
873
|
+
r.skipType(tag & 7)
|
|
844
874
|
break
|
|
845
875
|
}
|
|
846
876
|
}
|
|
@@ -975,7 +1005,7 @@ export namespace BitswapMessage {
|
|
|
975
1005
|
value: number
|
|
976
1006
|
}
|
|
977
1007
|
|
|
978
|
-
export function encode (obj:
|
|
1008
|
+
export function encode (obj: BitswapMessageInput): Uint8Array<ArrayBuffer> {
|
|
979
1009
|
return encodeMessage(obj, BitswapMessage.codec())
|
|
980
1010
|
}
|
|
981
1011
|
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"codec": "https://ipfs.github.io/helia/functions/_helia_bitswap.WantType.codec.html",
|
|
3
|
-
"WantType": "https://ipfs.github.io/helia/enums/_helia_bitswap.WantType.html",
|
|
4
|
-
"Bitswap": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.Bitswap.html",
|
|
5
|
-
".:Bitswap": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.Bitswap.html",
|
|
6
|
-
"BitswapBlockBrokerInit": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapBlockBrokerInit.html",
|
|
7
|
-
"BitswapComponents": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapComponents.html",
|
|
8
|
-
".:BitswapComponents": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapComponents.html",
|
|
9
|
-
"BitswapOptions": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapOptions.html",
|
|
10
|
-
".:BitswapOptions": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapOptions.html",
|
|
11
|
-
"BitswapProvider": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.BitswapProvider.html",
|
|
12
|
-
"PeerWantListEntry": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.PeerWantListEntry.html",
|
|
13
|
-
".:PeerWantListEntry": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.PeerWantListEntry.html",
|
|
14
|
-
"WantListEntry": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.WantListEntry.html",
|
|
15
|
-
".:WantListEntry": "https://ipfs.github.io/helia/interfaces/_helia_bitswap.WantListEntry.html",
|
|
16
|
-
"BitswapNetworkNotifyProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNetworkNotifyProgressEvents.html",
|
|
17
|
-
"BitswapNetworkProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNetworkProgressEvents.html",
|
|
18
|
-
"BitswapNetworkWantProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNetworkWantProgressEvents.html",
|
|
19
|
-
"BitswapNotifyProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNotifyProgressEvents.html",
|
|
20
|
-
".:BitswapNotifyProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapNotifyProgressEvents.html",
|
|
21
|
-
"BitswapWantBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapWantBlockProgressEvents.html",
|
|
22
|
-
".:BitswapWantBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapWantBlockProgressEvents.html",
|
|
23
|
-
"BitswapWantProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapWantProgressEvents.html",
|
|
24
|
-
".:BitswapWantProgressEvents": "https://ipfs.github.io/helia/types/_helia_bitswap.BitswapWantProgressEvents.html",
|
|
25
|
-
"WantStatus": "https://ipfs.github.io/helia/types/_helia_bitswap.WantStatus.html",
|
|
26
|
-
".:WantStatus": "https://ipfs.github.io/helia/types/_helia_bitswap.WantStatus.html",
|
|
27
|
-
"withBitswap": "https://ipfs.github.io/helia/functions/_helia_bitswap.withBitswap.html",
|
|
28
|
-
".:withBitswap": "https://ipfs.github.io/helia/functions/_helia_bitswap.withBitswap.html"
|
|
29
|
-
}
|