hypercore 11.0.23 → 11.0.25

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
@@ -208,6 +208,9 @@ class Hypercore extends EventEmitter {
208
208
  // in practice, open an issue and we'll try to make a solution for it.
209
209
  throw SESSION_CLOSED('Cannot make sessions on a closing core')
210
210
  }
211
+ if (opts.checkout !== undefined && !opts.name && !opts.atom) {
212
+ throw new Error('Checkouts are only supported on atoms or named sessions')
213
+ }
211
214
 
212
215
  const wait = opts.wait === false ? false : this.wait
213
216
  const writable = opts.writable === undefined ? !this._readonly : opts.writable === true
package/lib/core.js CHANGED
@@ -408,24 +408,25 @@ module.exports = class Core {
408
408
 
409
409
  _verifyBatchUpgrade (batch, manifest) {
410
410
  if (!this.header.manifest) {
411
- if (!manifest && this.compat) manifest = Verifier.defaultSignerManifest(this.header.key)
411
+ // compat, drop at some point
412
+ if (!manifest) manifest = Verifier.defaultSignerManifest(this.header.key)
412
413
 
413
- if (!manifest || !(Verifier.isValidManifest(this.header.key, manifest) || (this.compat && Verifier.isCompat(this.header.key, manifest)))) {
414
+ if (!manifest || !(Verifier.isValidManifest(this.header.key, manifest) || Verifier.isCompat(this.header.key, manifest))) {
414
415
  throw INVALID_SIGNATURE('Proof contains an invalid manifest') // TODO: proper error type
415
416
  }
416
417
  }
417
418
 
418
- manifest = Verifier.createManifest(manifest) // To unslab
419
-
420
- const verifier = this.verifier || new Verifier(this.header.key, manifest, { legacy: this._legacy })
421
-
419
+ const verifier = this.verifier || new Verifier(this.header.key, Verifier.createManifest(manifest), { legacy: this._legacy })
422
420
  if (!verifier.verify(batch, batch.signature)) {
423
421
  throw INVALID_SIGNATURE('Proof contains an invalid signature')
424
422
  }
423
+
424
+ return manifest
425
425
  }
426
426
 
427
427
  async _verifyExclusive ({ batch, bitfield, value, manifest }) {
428
- this._verifyBatchUpgrade(batch, manifest)
428
+ manifest = this._verifyBatchUpgrade(batch, manifest)
429
+
429
430
  if (!batch.commitable()) return false
430
431
 
431
432
  if (this.preupdate !== null) await this.preupdate(batch, this.header.key)
@@ -465,6 +465,9 @@ module.exports = class SessionState {
465
465
 
466
466
  if (this.isDefault()) {
467
467
  await storeBitfieldRange(this.storage, storage, batch.ancestors, batch.treeLength, false)
468
+ if (batch.ancestors < this.core.header.hints.contiguousLength) {
469
+ storage.setHints({ contiguousLength: batch.ancestors })
470
+ }
468
471
  }
469
472
 
470
473
  return { dependency, tree, roots: batch.roots }
@@ -476,7 +479,12 @@ module.exports = class SessionState {
476
479
  try {
477
480
  const tx = this.createWriteBatch()
478
481
 
479
- if (this.isDefault()) await storeBitfieldRange(this.storage, tx, start, end, false)
482
+ if (this.isDefault()) {
483
+ await storeBitfieldRange(this.storage, tx, start, end, false)
484
+ if (start < this.core.header.hints.contiguousLength) {
485
+ tx.setHints({ contiguousLength: start })
486
+ }
487
+ }
480
488
 
481
489
  this.blocks.clear(tx, start, end)
482
490
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.0.23",
3
+ "version": "11.0.25",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {