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 +12 -0
- package/lib/memory-overlay.js +1 -0
- package/lib/tip-list.js +1 -1
- package/package.json +1 -1
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
|
}
|
package/lib/memory-overlay.js
CHANGED
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')
|