hypercore-storage 3.0.0 → 3.0.1
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/encoding/spec/hyperschema/index.js +163 -163
- package/encoding/spec/hyperschema/schema.json +54 -54
- package/index.js +4 -0
- package/package.json +11 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is autogenerated by the hyperschema compiler
|
|
2
|
-
// Schema Version:
|
|
2
|
+
// Schema Version: 2
|
|
3
3
|
/* eslint-disable camelcase */
|
|
4
4
|
/* eslint-disable quotes */
|
|
5
5
|
/* eslint-disable space-before-function-paren */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
const { c } = require('hyperschema/runtime')
|
|
8
8
|
const external0 = require('../../external.js')
|
|
9
9
|
|
|
10
|
-
const VERSION =
|
|
10
|
+
const VERSION = 2
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line no-unused-vars
|
|
13
13
|
let version = VERSION
|
|
@@ -64,8 +64,99 @@ const encoding1 = {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
// @corestore/
|
|
67
|
+
// @corestore/head-v2
|
|
68
68
|
const encoding2 = {
|
|
69
|
+
preencode(state, m) {
|
|
70
|
+
c.uint.preencode(state, m.cores)
|
|
71
|
+
c.uint.preencode(state, m.datas)
|
|
72
|
+
c.uint.preencode(state, m.groups)
|
|
73
|
+
state.end++ // max flag is 2 so always one byte
|
|
74
|
+
|
|
75
|
+
if (m.seed) c.fixed32.preencode(state, m.seed)
|
|
76
|
+
if (m.defaultDiscoveryKey) c.fixed32.preencode(state, m.defaultDiscoveryKey)
|
|
77
|
+
},
|
|
78
|
+
encode(state, m) {
|
|
79
|
+
const flags = (m.seed ? 1 : 0) | (m.defaultDiscoveryKey ? 2 : 0)
|
|
80
|
+
|
|
81
|
+
c.uint.encode(state, m.cores)
|
|
82
|
+
c.uint.encode(state, m.datas)
|
|
83
|
+
c.uint.encode(state, m.groups)
|
|
84
|
+
c.uint.encode(state, flags)
|
|
85
|
+
|
|
86
|
+
if (m.seed) c.fixed32.encode(state, m.seed)
|
|
87
|
+
if (m.defaultDiscoveryKey) c.fixed32.encode(state, m.defaultDiscoveryKey)
|
|
88
|
+
},
|
|
89
|
+
decode(state) {
|
|
90
|
+
const v = c.uint.decode(state)
|
|
91
|
+
const r0 = c.uint.decode(state)
|
|
92
|
+
const r1 = c.uint.decode(state)
|
|
93
|
+
const r2 = c.uint.decode(state)
|
|
94
|
+
const flags = c.uint.decode(state)
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
version: v,
|
|
98
|
+
cores: r0,
|
|
99
|
+
datas: r1,
|
|
100
|
+
groups: r2,
|
|
101
|
+
seed: (flags & 1) !== 0 ? c.fixed32.decode(state) : null,
|
|
102
|
+
defaultDiscoveryKey: (flags & 2) !== 0 ? c.fixed32.decode(state) : null
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// @corestore/head
|
|
108
|
+
const encoding3 = {
|
|
109
|
+
preencode(state, m) {
|
|
110
|
+
c.uint.preencode(state, m.version)
|
|
111
|
+
switch (m.version) {
|
|
112
|
+
case 0:
|
|
113
|
+
case 1:
|
|
114
|
+
encoding1.preencode(state, m)
|
|
115
|
+
break
|
|
116
|
+
case 2:
|
|
117
|
+
encoding2.preencode(state, m)
|
|
118
|
+
break
|
|
119
|
+
default:
|
|
120
|
+
throw new Error('Unsupported version')
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
encode(state, m) {
|
|
124
|
+
c.uint.encode(state, m.version)
|
|
125
|
+
switch (m.version) {
|
|
126
|
+
case 0:
|
|
127
|
+
case 1:
|
|
128
|
+
encoding1.encode(state, m)
|
|
129
|
+
break
|
|
130
|
+
case 2:
|
|
131
|
+
encoding2.encode(state, m)
|
|
132
|
+
break
|
|
133
|
+
default:
|
|
134
|
+
throw new Error('Unsupported version')
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
decode(state) {
|
|
138
|
+
const start = state.start
|
|
139
|
+
const v = c.uint.decode(state)
|
|
140
|
+
state.start = start
|
|
141
|
+
switch (v) {
|
|
142
|
+
case 0:
|
|
143
|
+
case 1: {
|
|
144
|
+
const decoded = encoding1.decode(state)
|
|
145
|
+
const map = external0.headLegacyMap
|
|
146
|
+
return map(decoded)
|
|
147
|
+
}
|
|
148
|
+
case 2: {
|
|
149
|
+
const decoded = encoding2.decode(state)
|
|
150
|
+
return decoded
|
|
151
|
+
}
|
|
152
|
+
default:
|
|
153
|
+
throw new Error('Unsupported version')
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// @corestore/alias
|
|
159
|
+
const encoding4 = {
|
|
69
160
|
preencode(state, m) {
|
|
70
161
|
c.string.preencode(state, m.name)
|
|
71
162
|
c.fixed32.preencode(state, m.namespace)
|
|
@@ -86,14 +177,14 @@ const encoding2 = {
|
|
|
86
177
|
}
|
|
87
178
|
|
|
88
179
|
// @corestore/core
|
|
89
|
-
const
|
|
180
|
+
const encoding5 = {
|
|
90
181
|
preencode(state, m) {
|
|
91
182
|
c.uint.preencode(state, m.version)
|
|
92
183
|
c.uint.preencode(state, m.corePointer)
|
|
93
184
|
c.uint.preencode(state, m.dataPointer)
|
|
94
185
|
state.end++ // max flag is 1 so always one byte
|
|
95
186
|
|
|
96
|
-
if (m.alias)
|
|
187
|
+
if (m.alias) encoding4.preencode(state, m.alias)
|
|
97
188
|
},
|
|
98
189
|
encode(state, m) {
|
|
99
190
|
const flags = m.alias ? 1 : 0
|
|
@@ -103,7 +194,7 @@ const encoding3 = {
|
|
|
103
194
|
c.uint.encode(state, m.dataPointer)
|
|
104
195
|
c.uint.encode(state, flags)
|
|
105
196
|
|
|
106
|
-
if (m.alias)
|
|
197
|
+
if (m.alias) encoding4.encode(state, m.alias)
|
|
107
198
|
},
|
|
108
199
|
decode(state) {
|
|
109
200
|
const r0 = c.uint.decode(state)
|
|
@@ -115,17 +206,17 @@ const encoding3 = {
|
|
|
115
206
|
version: r0,
|
|
116
207
|
corePointer: r1,
|
|
117
208
|
dataPointer: r2,
|
|
118
|
-
alias: (flags & 1) !== 0 ?
|
|
209
|
+
alias: (flags & 1) !== 0 ? encoding4.decode(state) : null
|
|
119
210
|
}
|
|
120
211
|
}
|
|
121
212
|
}
|
|
122
213
|
|
|
123
|
-
const
|
|
214
|
+
const encoding6_enum = {
|
|
124
215
|
blake2b: 'blake2b'
|
|
125
216
|
}
|
|
126
217
|
|
|
127
218
|
// @core/hashes enum
|
|
128
|
-
const
|
|
219
|
+
const encoding6 = {
|
|
129
220
|
preencode(state, m) {
|
|
130
221
|
state.end++ // max enum is 0 so always one byte
|
|
131
222
|
},
|
|
@@ -148,12 +239,12 @@ const encoding4 = {
|
|
|
148
239
|
}
|
|
149
240
|
}
|
|
150
241
|
|
|
151
|
-
const
|
|
242
|
+
const encoding7_enum = {
|
|
152
243
|
ed25519: 'ed25519'
|
|
153
244
|
}
|
|
154
245
|
|
|
155
246
|
// @core/signatures enum
|
|
156
|
-
const
|
|
247
|
+
const encoding7 = {
|
|
157
248
|
preencode(state, m) {
|
|
158
249
|
state.end++ // max enum is 0 so always one byte
|
|
159
250
|
},
|
|
@@ -177,7 +268,7 @@ const encoding5 = {
|
|
|
177
268
|
}
|
|
178
269
|
|
|
179
270
|
// @core/tree-node
|
|
180
|
-
const
|
|
271
|
+
const encoding8 = {
|
|
181
272
|
preencode(state, m) {
|
|
182
273
|
c.uint.preencode(state, m.index)
|
|
183
274
|
c.uint.preencode(state, m.size)
|
|
@@ -202,19 +293,19 @@ const encoding6 = {
|
|
|
202
293
|
}
|
|
203
294
|
|
|
204
295
|
// @core/signer
|
|
205
|
-
const
|
|
296
|
+
const encoding9 = {
|
|
206
297
|
preencode(state, m) {
|
|
207
|
-
|
|
298
|
+
encoding7.preencode(state, m.signature)
|
|
208
299
|
c.fixed32.preencode(state, m.namespace)
|
|
209
300
|
c.fixed32.preencode(state, m.publicKey)
|
|
210
301
|
},
|
|
211
302
|
encode(state, m) {
|
|
212
|
-
|
|
303
|
+
encoding7.encode(state, m.signature)
|
|
213
304
|
c.fixed32.encode(state, m.namespace)
|
|
214
305
|
c.fixed32.encode(state, m.publicKey)
|
|
215
306
|
},
|
|
216
307
|
decode(state) {
|
|
217
|
-
const r0 =
|
|
308
|
+
const r0 = encoding7.decode(state)
|
|
218
309
|
const r1 = c.fixed32.decode(state)
|
|
219
310
|
const r2 = c.fixed32.decode(state)
|
|
220
311
|
|
|
@@ -227,7 +318,7 @@ const encoding7 = {
|
|
|
227
318
|
}
|
|
228
319
|
|
|
229
320
|
// @core/prologue
|
|
230
|
-
const
|
|
321
|
+
const encoding10 = {
|
|
231
322
|
preencode(state, m) {
|
|
232
323
|
c.fixed32.preencode(state, m.hash)
|
|
233
324
|
c.uint.preencode(state, m.length)
|
|
@@ -248,21 +339,21 @@ const encoding8 = {
|
|
|
248
339
|
}
|
|
249
340
|
|
|
250
341
|
// @core/manifest.signers
|
|
251
|
-
const
|
|
342
|
+
const encoding11_4 = c.array(encoding9)
|
|
252
343
|
// @core/manifest.linked
|
|
253
|
-
const
|
|
344
|
+
const encoding11_6 = c.array(c.fixed32)
|
|
254
345
|
|
|
255
346
|
// @core/manifest
|
|
256
|
-
const
|
|
347
|
+
const encoding11 = {
|
|
257
348
|
preencode(state, m) {
|
|
258
349
|
c.uint.preencode(state, m.version)
|
|
259
350
|
state.end++ // max flag is 8 so always one byte
|
|
260
|
-
|
|
351
|
+
encoding6.preencode(state, m.hash)
|
|
261
352
|
c.uint.preencode(state, m.quorum)
|
|
262
|
-
|
|
353
|
+
encoding11_4.preencode(state, m.signers)
|
|
263
354
|
|
|
264
|
-
if (m.prologue)
|
|
265
|
-
if (m.linked)
|
|
355
|
+
if (m.prologue) encoding10.preencode(state, m.prologue)
|
|
356
|
+
if (m.linked) encoding11_6.preencode(state, m.linked)
|
|
266
357
|
if (m.userData) c.buffer.preencode(state, m.userData)
|
|
267
358
|
},
|
|
268
359
|
encode(state, m) {
|
|
@@ -271,12 +362,12 @@ const encoding9 = {
|
|
|
271
362
|
|
|
272
363
|
c.uint.encode(state, m.version)
|
|
273
364
|
c.uint.encode(state, flags)
|
|
274
|
-
|
|
365
|
+
encoding6.encode(state, m.hash)
|
|
275
366
|
c.uint.encode(state, m.quorum)
|
|
276
|
-
|
|
367
|
+
encoding11_4.encode(state, m.signers)
|
|
277
368
|
|
|
278
|
-
if (m.prologue)
|
|
279
|
-
if (m.linked)
|
|
369
|
+
if (m.prologue) encoding10.encode(state, m.prologue)
|
|
370
|
+
if (m.linked) encoding11_6.encode(state, m.linked)
|
|
280
371
|
if (m.userData) c.buffer.encode(state, m.userData)
|
|
281
372
|
},
|
|
282
373
|
decode(state) {
|
|
@@ -285,19 +376,19 @@ const encoding9 = {
|
|
|
285
376
|
|
|
286
377
|
return {
|
|
287
378
|
version: r0,
|
|
288
|
-
hash:
|
|
379
|
+
hash: encoding6.decode(state),
|
|
289
380
|
quorum: c.uint.decode(state),
|
|
290
381
|
allowPatch: (flags & 1) !== 0,
|
|
291
|
-
signers:
|
|
292
|
-
prologue: (flags & 2) !== 0 ?
|
|
293
|
-
linked: (flags & 4) !== 0 ?
|
|
382
|
+
signers: encoding11_4.decode(state),
|
|
383
|
+
prologue: (flags & 2) !== 0 ? encoding10.decode(state) : null,
|
|
384
|
+
linked: (flags & 4) !== 0 ? encoding11_6.decode(state) : null,
|
|
294
385
|
userData: (flags & 8) !== 0 ? c.buffer.decode(state) : null
|
|
295
386
|
}
|
|
296
387
|
}
|
|
297
388
|
}
|
|
298
389
|
|
|
299
390
|
// @core/keyPair
|
|
300
|
-
const
|
|
391
|
+
const encoding12 = {
|
|
301
392
|
preencode(state, m) {
|
|
302
393
|
c.buffer.preencode(state, m.publicKey)
|
|
303
394
|
c.optionalBuffer.preencode(state, m.secretKey)
|
|
@@ -318,7 +409,7 @@ const encoding10 = {
|
|
|
318
409
|
}
|
|
319
410
|
|
|
320
411
|
// @core/group
|
|
321
|
-
const
|
|
412
|
+
const encoding13 = {
|
|
322
413
|
preencode(state, m) {
|
|
323
414
|
state.end++ // max flag is 2 so always one byte
|
|
324
415
|
|
|
@@ -344,17 +435,17 @@ const encoding11 = {
|
|
|
344
435
|
}
|
|
345
436
|
|
|
346
437
|
// @core/auth.manifest
|
|
347
|
-
const
|
|
438
|
+
const encoding14_2 = c.frame(encoding11)
|
|
348
439
|
|
|
349
440
|
// @core/auth
|
|
350
|
-
const
|
|
441
|
+
const encoding14 = {
|
|
351
442
|
preencode(state, m) {
|
|
352
443
|
c.fixed32.preencode(state, m.key)
|
|
353
444
|
c.fixed32.preencode(state, m.discoveryKey)
|
|
354
445
|
state.end++ // max flag is 4 so always one byte
|
|
355
446
|
|
|
356
|
-
if (m.manifest)
|
|
357
|
-
if (m.keyPair)
|
|
447
|
+
if (m.manifest) encoding14_2.preencode(state, m.manifest)
|
|
448
|
+
if (m.keyPair) encoding12.preencode(state, m.keyPair)
|
|
358
449
|
if (m.encryptionKey) c.buffer.preencode(state, m.encryptionKey)
|
|
359
450
|
},
|
|
360
451
|
encode(state, m) {
|
|
@@ -364,8 +455,8 @@ const encoding12 = {
|
|
|
364
455
|
c.fixed32.encode(state, m.discoveryKey)
|
|
365
456
|
c.uint.encode(state, flags)
|
|
366
457
|
|
|
367
|
-
if (m.manifest)
|
|
368
|
-
if (m.keyPair)
|
|
458
|
+
if (m.manifest) encoding14_2.encode(state, m.manifest)
|
|
459
|
+
if (m.keyPair) encoding12.encode(state, m.keyPair)
|
|
369
460
|
if (m.encryptionKey) c.buffer.encode(state, m.encryptionKey)
|
|
370
461
|
},
|
|
371
462
|
decode(state) {
|
|
@@ -376,15 +467,15 @@ const encoding12 = {
|
|
|
376
467
|
return {
|
|
377
468
|
key: r0,
|
|
378
469
|
discoveryKey: r1,
|
|
379
|
-
manifest: (flags & 1) !== 0 ?
|
|
380
|
-
keyPair: (flags & 2) !== 0 ?
|
|
470
|
+
manifest: (flags & 1) !== 0 ? encoding14_2.decode(state) : null,
|
|
471
|
+
keyPair: (flags & 2) !== 0 ? encoding12.decode(state) : null,
|
|
381
472
|
encryptionKey: (flags & 4) !== 0 ? c.buffer.decode(state) : null
|
|
382
473
|
}
|
|
383
474
|
}
|
|
384
475
|
}
|
|
385
476
|
|
|
386
477
|
// @core/head
|
|
387
|
-
const
|
|
478
|
+
const encoding15 = {
|
|
388
479
|
preencode(state, m) {
|
|
389
480
|
c.uint.preencode(state, m.fork)
|
|
390
481
|
c.uint.preencode(state, m.length)
|
|
@@ -392,10 +483,10 @@ const encoding13 = {
|
|
|
392
483
|
c.optionalBuffer.preencode(state, m.signature)
|
|
393
484
|
state.end++ // max flag is 1 so always one byte
|
|
394
485
|
|
|
395
|
-
if (m.timestamp) c.uint64.preencode(state, m.timestamp)
|
|
486
|
+
if (version >= 2 && m.timestamp) c.uint64.preencode(state, m.timestamp)
|
|
396
487
|
},
|
|
397
488
|
encode(state, m) {
|
|
398
|
-
const flags = m.timestamp ? 1 : 0
|
|
489
|
+
const flags = version >= 2 && m.timestamp ? 1 : 0
|
|
399
490
|
|
|
400
491
|
c.uint.encode(state, m.fork)
|
|
401
492
|
c.uint.encode(state, m.length)
|
|
@@ -403,27 +494,27 @@ const encoding13 = {
|
|
|
403
494
|
c.optionalBuffer.encode(state, m.signature)
|
|
404
495
|
c.uint.encode(state, flags)
|
|
405
496
|
|
|
406
|
-
if (m.timestamp) c.uint64.encode(state, m.timestamp)
|
|
497
|
+
if (version >= 2 && m.timestamp) c.uint64.encode(state, m.timestamp)
|
|
407
498
|
},
|
|
408
499
|
decode(state) {
|
|
409
500
|
const r0 = c.uint.decode(state)
|
|
410
501
|
const r1 = c.uint.decode(state)
|
|
411
502
|
const r2 = c.fixed32.decode(state)
|
|
412
503
|
const r3 = c.optionalBuffer.decode(state)
|
|
413
|
-
const flags = c.uint.decode(state)
|
|
504
|
+
const flags = state.start < state.end ? c.uint.decode(state) : 0
|
|
414
505
|
|
|
415
506
|
return {
|
|
416
507
|
fork: r0,
|
|
417
508
|
length: r1,
|
|
418
509
|
rootHash: r2,
|
|
419
510
|
signature: r3,
|
|
420
|
-
timestamp: (flags & 1) !== 0 ? c.uint64.decode(state) : 0
|
|
511
|
+
timestamp: version >= 2 && (flags & 1) !== 0 ? c.uint64.decode(state) : 0
|
|
421
512
|
}
|
|
422
513
|
}
|
|
423
514
|
}
|
|
424
515
|
|
|
425
516
|
// @core/hints
|
|
426
|
-
const
|
|
517
|
+
const encoding16 = {
|
|
427
518
|
preencode(state, m) {
|
|
428
519
|
state.end++ // max flag is 4 so always one byte
|
|
429
520
|
|
|
@@ -453,7 +544,7 @@ const encoding14 = {
|
|
|
453
544
|
}
|
|
454
545
|
|
|
455
546
|
// @core/session
|
|
456
|
-
const
|
|
547
|
+
const encoding17 = {
|
|
457
548
|
preencode(state, m) {
|
|
458
549
|
c.string.preencode(state, m.name)
|
|
459
550
|
c.uint.preencode(state, m.dataPointer)
|
|
@@ -474,10 +565,10 @@ const encoding15 = {
|
|
|
474
565
|
}
|
|
475
566
|
|
|
476
567
|
// @core/sessions
|
|
477
|
-
const
|
|
568
|
+
const encoding18 = c.array(encoding17)
|
|
478
569
|
|
|
479
570
|
// @core/dependency
|
|
480
|
-
const
|
|
571
|
+
const encoding19 = {
|
|
481
572
|
preencode(state, m) {
|
|
482
573
|
c.uint.preencode(state, m.dataPointer)
|
|
483
574
|
c.uint.preencode(state, m.length)
|
|
@@ -497,97 +588,6 @@ const encoding17 = {
|
|
|
497
588
|
}
|
|
498
589
|
}
|
|
499
590
|
|
|
500
|
-
// @corestore/head-v2
|
|
501
|
-
const encoding18 = {
|
|
502
|
-
preencode(state, m) {
|
|
503
|
-
c.uint.preencode(state, m.cores)
|
|
504
|
-
c.uint.preencode(state, m.datas)
|
|
505
|
-
c.uint.preencode(state, m.groups)
|
|
506
|
-
state.end++ // max flag is 2 so always one byte
|
|
507
|
-
|
|
508
|
-
if (m.seed) c.fixed32.preencode(state, m.seed)
|
|
509
|
-
if (m.defaultDiscoveryKey) c.fixed32.preencode(state, m.defaultDiscoveryKey)
|
|
510
|
-
},
|
|
511
|
-
encode(state, m) {
|
|
512
|
-
const flags = (m.seed ? 1 : 0) | (m.defaultDiscoveryKey ? 2 : 0)
|
|
513
|
-
|
|
514
|
-
c.uint.encode(state, m.cores)
|
|
515
|
-
c.uint.encode(state, m.datas)
|
|
516
|
-
c.uint.encode(state, m.groups)
|
|
517
|
-
c.uint.encode(state, flags)
|
|
518
|
-
|
|
519
|
-
if (m.seed) c.fixed32.encode(state, m.seed)
|
|
520
|
-
if (m.defaultDiscoveryKey) c.fixed32.encode(state, m.defaultDiscoveryKey)
|
|
521
|
-
},
|
|
522
|
-
decode(state) {
|
|
523
|
-
const v = c.uint.decode(state)
|
|
524
|
-
const r0 = c.uint.decode(state)
|
|
525
|
-
const r1 = c.uint.decode(state)
|
|
526
|
-
const r2 = c.uint.decode(state)
|
|
527
|
-
const flags = c.uint.decode(state)
|
|
528
|
-
|
|
529
|
-
return {
|
|
530
|
-
version: v,
|
|
531
|
-
cores: r0,
|
|
532
|
-
datas: r1,
|
|
533
|
-
groups: r2,
|
|
534
|
-
seed: (flags & 1) !== 0 ? c.fixed32.decode(state) : null,
|
|
535
|
-
defaultDiscoveryKey: (flags & 2) !== 0 ? c.fixed32.decode(state) : null
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
// @corestore/head
|
|
541
|
-
const encoding19 = {
|
|
542
|
-
preencode(state, m) {
|
|
543
|
-
c.uint.preencode(state, m.version)
|
|
544
|
-
switch (m.version) {
|
|
545
|
-
case 0:
|
|
546
|
-
case 1:
|
|
547
|
-
encoding1.preencode(state, m)
|
|
548
|
-
break
|
|
549
|
-
case 2:
|
|
550
|
-
encoding18.preencode(state, m)
|
|
551
|
-
break
|
|
552
|
-
default:
|
|
553
|
-
throw new Error('Unsupported version')
|
|
554
|
-
}
|
|
555
|
-
},
|
|
556
|
-
encode(state, m) {
|
|
557
|
-
c.uint.encode(state, m.version)
|
|
558
|
-
switch (m.version) {
|
|
559
|
-
case 0:
|
|
560
|
-
case 1:
|
|
561
|
-
encoding1.encode(state, m)
|
|
562
|
-
break
|
|
563
|
-
case 2:
|
|
564
|
-
encoding18.encode(state, m)
|
|
565
|
-
break
|
|
566
|
-
default:
|
|
567
|
-
throw new Error('Unsupported version')
|
|
568
|
-
}
|
|
569
|
-
},
|
|
570
|
-
decode(state) {
|
|
571
|
-
const start = state.start
|
|
572
|
-
const v = c.uint.decode(state)
|
|
573
|
-
state.start = start
|
|
574
|
-
switch (v) {
|
|
575
|
-
case 0:
|
|
576
|
-
case 1: {
|
|
577
|
-
const decoded = encoding1.decode(state)
|
|
578
|
-
const map = external0.headLegacyMap
|
|
579
|
-
return map(decoded)
|
|
580
|
-
}
|
|
581
|
-
case 2: {
|
|
582
|
-
const decoded = encoding18.decode(state)
|
|
583
|
-
return decoded
|
|
584
|
-
}
|
|
585
|
-
default:
|
|
586
|
-
throw new Error('Unsupported version')
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
591
|
function setVersion(v) {
|
|
592
592
|
version = v
|
|
593
593
|
}
|
|
@@ -605,9 +605,9 @@ function decode(name, buffer, v = VERSION) {
|
|
|
605
605
|
function getEnum(name) {
|
|
606
606
|
switch (name) {
|
|
607
607
|
case '@core/hashes':
|
|
608
|
-
return
|
|
608
|
+
return encoding6_enum
|
|
609
609
|
case '@core/signatures':
|
|
610
|
-
return
|
|
610
|
+
return encoding7_enum
|
|
611
611
|
default:
|
|
612
612
|
throw new Error('Enum not found ' + name)
|
|
613
613
|
}
|
|
@@ -619,41 +619,41 @@ function getEncoding(name) {
|
|
|
619
619
|
return encoding0
|
|
620
620
|
case '@corestore/head-v1':
|
|
621
621
|
return encoding1
|
|
622
|
-
case '@corestore/
|
|
622
|
+
case '@corestore/head-v2':
|
|
623
623
|
return encoding2
|
|
624
|
-
case '@corestore/
|
|
624
|
+
case '@corestore/head':
|
|
625
625
|
return encoding3
|
|
626
|
-
case '@
|
|
626
|
+
case '@corestore/alias':
|
|
627
627
|
return encoding4
|
|
628
|
-
case '@core
|
|
628
|
+
case '@corestore/core':
|
|
629
629
|
return encoding5
|
|
630
|
-
case '@core/
|
|
630
|
+
case '@core/hashes':
|
|
631
631
|
return encoding6
|
|
632
|
-
case '@core/
|
|
632
|
+
case '@core/signatures':
|
|
633
633
|
return encoding7
|
|
634
|
-
case '@core/
|
|
634
|
+
case '@core/tree-node':
|
|
635
635
|
return encoding8
|
|
636
|
-
case '@core/
|
|
636
|
+
case '@core/signer':
|
|
637
637
|
return encoding9
|
|
638
|
-
case '@core/
|
|
638
|
+
case '@core/prologue':
|
|
639
639
|
return encoding10
|
|
640
|
-
case '@core/
|
|
640
|
+
case '@core/manifest':
|
|
641
641
|
return encoding11
|
|
642
|
-
case '@core/
|
|
642
|
+
case '@core/keyPair':
|
|
643
643
|
return encoding12
|
|
644
|
-
case '@core/
|
|
644
|
+
case '@core/group':
|
|
645
645
|
return encoding13
|
|
646
|
-
case '@core/
|
|
646
|
+
case '@core/auth':
|
|
647
647
|
return encoding14
|
|
648
|
-
case '@core/
|
|
648
|
+
case '@core/head':
|
|
649
649
|
return encoding15
|
|
650
|
-
case '@core/
|
|
650
|
+
case '@core/hints':
|
|
651
651
|
return encoding16
|
|
652
|
-
case '@core/
|
|
652
|
+
case '@core/session':
|
|
653
653
|
return encoding17
|
|
654
|
-
case '@
|
|
654
|
+
case '@core/sessions':
|
|
655
655
|
return encoding18
|
|
656
|
-
case '@
|
|
656
|
+
case '@core/dependency':
|
|
657
657
|
return encoding19
|
|
658
658
|
default:
|
|
659
659
|
throw new Error('Encoder not found ' + name)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"schema": [
|
|
4
4
|
{
|
|
5
5
|
"name": "allocated",
|
|
@@ -44,6 +44,58 @@
|
|
|
44
44
|
}
|
|
45
45
|
]
|
|
46
46
|
},
|
|
47
|
+
{
|
|
48
|
+
"name": "head-v2",
|
|
49
|
+
"namespace": "corestore",
|
|
50
|
+
"compact": false,
|
|
51
|
+
"flagsPosition": 3,
|
|
52
|
+
"fields": [
|
|
53
|
+
{
|
|
54
|
+
"name": "cores",
|
|
55
|
+
"required": true,
|
|
56
|
+
"type": "uint",
|
|
57
|
+
"version": 1
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "datas",
|
|
61
|
+
"required": true,
|
|
62
|
+
"type": "uint",
|
|
63
|
+
"version": 1
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "groups",
|
|
67
|
+
"required": true,
|
|
68
|
+
"type": "uint",
|
|
69
|
+
"version": 1
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "seed",
|
|
73
|
+
"type": "fixed32",
|
|
74
|
+
"version": 1
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "defaultDiscoveryKey",
|
|
78
|
+
"type": "fixed32",
|
|
79
|
+
"version": 1
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "head",
|
|
85
|
+
"namespace": "corestore",
|
|
86
|
+
"versions": [
|
|
87
|
+
{
|
|
88
|
+
"type": "@corestore/head-v1",
|
|
89
|
+
"map": "headLegacyMap",
|
|
90
|
+
"version": 1
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"type": "@corestore/head-v2",
|
|
94
|
+
"map": null,
|
|
95
|
+
"version": 2
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
47
99
|
{
|
|
48
100
|
"name": "alias",
|
|
49
101
|
"namespace": "corestore",
|
|
@@ -352,7 +404,7 @@
|
|
|
352
404
|
"name": "timestamp",
|
|
353
405
|
"required": false,
|
|
354
406
|
"type": "uint64",
|
|
355
|
-
"version":
|
|
407
|
+
"version": 2
|
|
356
408
|
}
|
|
357
409
|
]
|
|
358
410
|
},
|
|
@@ -424,58 +476,6 @@
|
|
|
424
476
|
"version": 1
|
|
425
477
|
}
|
|
426
478
|
]
|
|
427
|
-
},
|
|
428
|
-
{
|
|
429
|
-
"name": "head-v2",
|
|
430
|
-
"namespace": "corestore",
|
|
431
|
-
"compact": false,
|
|
432
|
-
"flagsPosition": 3,
|
|
433
|
-
"fields": [
|
|
434
|
-
{
|
|
435
|
-
"name": "cores",
|
|
436
|
-
"required": true,
|
|
437
|
-
"type": "uint",
|
|
438
|
-
"version": 1
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
"name": "datas",
|
|
442
|
-
"required": true,
|
|
443
|
-
"type": "uint",
|
|
444
|
-
"version": 1
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
"name": "groups",
|
|
448
|
-
"required": true,
|
|
449
|
-
"type": "uint",
|
|
450
|
-
"version": 1
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
"name": "seed",
|
|
454
|
-
"type": "fixed32",
|
|
455
|
-
"version": 1
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
"name": "defaultDiscoveryKey",
|
|
459
|
-
"type": "fixed32",
|
|
460
|
-
"version": 1
|
|
461
|
-
}
|
|
462
|
-
]
|
|
463
|
-
},
|
|
464
|
-
{
|
|
465
|
-
"name": "head",
|
|
466
|
-
"namespace": "corestore",
|
|
467
|
-
"versions": [
|
|
468
|
-
{
|
|
469
|
-
"type": "@corestore/head-v1",
|
|
470
|
-
"map": "headLegacyMap",
|
|
471
|
-
"version": 1
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
"type": "@corestore/head-v2",
|
|
475
|
-
"map": null,
|
|
476
|
-
"version": 2
|
|
477
|
-
}
|
|
478
|
-
]
|
|
479
479
|
}
|
|
480
480
|
]
|
|
481
481
|
}
|
package/index.js
CHANGED
|
@@ -679,6 +679,10 @@ class CorestoreStorage {
|
|
|
679
679
|
await require('./migrations/0').core(core, target)
|
|
680
680
|
break
|
|
681
681
|
}
|
|
682
|
+
case 1: {
|
|
683
|
+
await require('./migrations/1').core(core, target)
|
|
684
|
+
break
|
|
685
|
+
}
|
|
682
686
|
default: {
|
|
683
687
|
throw new Error(
|
|
684
688
|
'Unsupported version: ' + version + ' - you should probably upgrade your dependencies'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypercore-storage",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"index.js",
|
|
@@ -24,6 +24,14 @@
|
|
|
24
24
|
"bare": "bare-fs",
|
|
25
25
|
"default": "fs"
|
|
26
26
|
},
|
|
27
|
+
"fs/*": {
|
|
28
|
+
"bare": "bare-fs/*",
|
|
29
|
+
"default": "fs/*"
|
|
30
|
+
},
|
|
31
|
+
"os": {
|
|
32
|
+
"bare": "bare-os",
|
|
33
|
+
"default": "os"
|
|
34
|
+
},
|
|
27
35
|
"path": {
|
|
28
36
|
"bare": "bare-path",
|
|
29
37
|
"default": "path"
|
|
@@ -39,7 +47,6 @@
|
|
|
39
47
|
"homepage": "https://github.com/holepunchto/hypercore-storage#readme",
|
|
40
48
|
"dependencies": {
|
|
41
49
|
"b4a": "^1.6.7",
|
|
42
|
-
"bare-fs": "^4.0.1",
|
|
43
50
|
"bare-path": "^3.0.0",
|
|
44
51
|
"compact-encoding": "^3.1.0",
|
|
45
52
|
"device-file": "^2.1.2",
|
|
@@ -53,7 +60,9 @@
|
|
|
53
60
|
"streamx": "^2.21.1"
|
|
54
61
|
},
|
|
55
62
|
"devDependencies": {
|
|
63
|
+
"bare-os": "^3.9.1",
|
|
56
64
|
"brittle": "^3.7.0",
|
|
65
|
+
"hypercore-storage-2.9.0": "npm:hypercore-storage@^2.9.0",
|
|
57
66
|
"lunte": "^1.3.0",
|
|
58
67
|
"prettier": "^3.6.2",
|
|
59
68
|
"prettier-config-holepunch": "^2.0.0",
|