hypercore-storage 0.0.29 → 0.0.30

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
@@ -471,6 +471,18 @@ class HypercoreStorage {
471
471
  }
472
472
  }
473
473
 
474
+ async registerOverlay (head) {
475
+ const storage = new MemoryOverlay(this)
476
+ const batch = storage.createWriteBatch()
477
+
478
+ batch.setDataDependency({ data: this.dataPointer, length: head.length })
479
+ if (head.rootHash) batch.setCoreHead(head) // if no root hash its the empty core - no head yet
480
+
481
+ await batch.flush()
482
+
483
+ return storage
484
+ }
485
+
474
486
  createMemoryOverlay () {
475
487
  return new MemoryOverlay(this)
476
488
  }
@@ -196,6 +196,7 @@ class MemoryOverlay {
196
196
  }
197
197
 
198
198
  createBitfieldPageStream (opts) {
199
+ if (this.bitfields === null) return createBitfieldPageStream(this.storage)
199
200
  return new OverlayStream(this.bitfields, this.storage, createBitfieldPageStream, opts)
200
201
  }
201
202
 
package/lib/tip-list.js CHANGED
@@ -78,7 +78,7 @@ module.exports = class TipList {
78
78
  }
79
79
 
80
80
  merge (tip) {
81
- const invalidDeletion = tip.removed && tip.end() !== -1 && tip.end() < this.end()
81
+ const invalidDeletion = tip.removed > 0 && tip.end() !== -1 && tip.end() < this.end()
82
82
  const invalidTip = (tip.removed !== -1 && tip.end() < this.offset) || this.end() < tip.offset
83
83
 
84
84
  if (invalidTip || invalidDeletion) throw ASSERTION('Cannot merge tip list')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-storage",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",