hypercore-storage 1.9.5 → 1.10.0

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/index.js CHANGED
@@ -406,10 +406,12 @@ class CorestoreStorage {
406
406
  const end = core.core(ptr.corePointer + 1)
407
407
  tx.tryDeleteRange(start, end)
408
408
 
409
- for (const { dataPointer } of sessions) {
410
- const start = core.data(dataPointer)
411
- const end = core.data(dataPointer + 1)
412
- tx.tryDeleteRange(start, end)
409
+ if (sessions) {
410
+ for (const { dataPointer } of sessions) {
411
+ const start = core.data(dataPointer)
412
+ const end = core.data(dataPointer + 1)
413
+ tx.tryDeleteRange(start, end)
414
+ }
413
415
  }
414
416
 
415
417
  return tx.flush()
@@ -373,7 +373,7 @@ async function core (core, { version, dryRun = true, gc = true }) {
373
373
  }
374
374
 
375
375
  const oplog = await readOplog(files.oplog)
376
- if (!oplog) throw new Error('No oplog available for ' + files.oplog)
376
+ if (!oplog) throw new Error('No oplog available for ' + files.oplog + ', length = ' + (head ? head.length : 0) + ', writable = ' + (!!auth.keyPair))
377
377
 
378
378
  const treeData = new TreeSlicer()
379
379
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "1.9.5",
3
+ "version": "1.10.0",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",
@@ -245,6 +245,8 @@ const encoding8 = {
245
245
 
246
246
  // @core/manifest.signers
247
247
  const encoding9_4 = c.array(encoding7)
248
+ // @core/manifest.linked
249
+ const encoding9_6 = c.array(c.fixed32)
248
250
 
249
251
  // @core/manifest
250
252
  const encoding9 = {
@@ -256,12 +258,13 @@ const encoding9 = {
256
258
  encoding9_4.preencode(state, m.signers)
257
259
 
258
260
  if (m.prologue) encoding8.preencode(state, m.prologue)
261
+ if (m.linked) encoding9_6.preencode(state, m.linked)
259
262
  },
260
263
  encode (state, m) {
261
264
  const flags =
262
265
  (m.allowPatch ? 1 : 0) |
263
266
  (m.prologue ? 2 : 0) |
264
- (m.unencrypted ? 4 : 0)
267
+ (m.linked ? 4 : 0)
265
268
 
266
269
  c.uint.encode(state, m.version)
267
270
  c.uint.encode(state, flags)
@@ -270,6 +273,7 @@ const encoding9 = {
270
273
  encoding9_4.encode(state, m.signers)
271
274
 
272
275
  if (m.prologue) encoding8.encode(state, m.prologue)
276
+ if (m.linked) encoding9_6.encode(state, m.linked)
273
277
  },
274
278
  decode (state) {
275
279
  const r0 = c.uint.decode(state)
@@ -282,7 +286,7 @@ const encoding9 = {
282
286
  allowPatch: (flags & 1) !== 0,
283
287
  signers: encoding9_4.decode(state),
284
288
  prologue: (flags & 2) !== 0 ? encoding8.decode(state) : null,
285
- unencrypted: (flags & 4) !== 0
289
+ linked: (flags & 4) !== 0 ? encoding9_6.decode(state) : null
286
290
  }
287
291
  }
288
292
  }