hypercore-storage 1.8.4 → 1.8.6

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
@@ -667,7 +667,7 @@ class CorestoreStorage {
667
667
  }
668
668
  }
669
669
 
670
- async has (discoveryKey) {
670
+ async has (discoveryKey, { ifMigrated = false } = {}) {
671
671
  if (this.version === 0) await this._migrateStore()
672
672
 
673
673
  const rx = new CorestoreRX(this.db, EMPTY)
@@ -675,7 +675,12 @@ class CorestoreStorage {
675
675
 
676
676
  rx.tryFlush()
677
677
 
678
- return (await promise) !== null
678
+ const core = await promise
679
+
680
+ if (core === null) return false
681
+ if (core.version !== VERSION && !ifMigrated) return false
682
+
683
+ return true
679
684
  }
680
685
 
681
686
  async getAuth (discoveryKey) {
@@ -433,6 +433,7 @@ async function core (core, { version, dryRun = true, gc = true }) {
433
433
 
434
434
  for (const index of allBits(bitfield)) {
435
435
  if (headerBits.get(index) === false) continue
436
+ if (index >= head.length) continue
436
437
 
437
438
  setBitInPage(index)
438
439
 
@@ -451,6 +452,7 @@ async function core (core, { version, dryRun = true, gc = true }) {
451
452
 
452
453
  for (const [index, bit] of headerBits) {
453
454
  if (!bit) continue
455
+ if (index >= head.length) continue
454
456
 
455
457
  setBitInPage(index)
456
458
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",