hypercore-storage 1.0.6 → 1.0.7
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 +18 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -104,7 +104,7 @@ class HypercoreStorage {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
snapshot () {
|
|
107
|
-
return new HypercoreStorage(this.store, this.db.snapshot(), this.core, this.view.snapshot(), this.atom)
|
|
107
|
+
return new HypercoreStorage(this.store, this.db.snapshot(), cloneCore(this.core), this.view.snapshot(), this.atom)
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
atomize (atom) {
|
|
@@ -212,13 +212,12 @@ class HypercoreStorage {
|
|
|
212
212
|
version: this.core.version,
|
|
213
213
|
corePointer: this.core.corePointer,
|
|
214
214
|
dataPointer: this.core.dataPointer,
|
|
215
|
-
dependencies: this._addDependency(
|
|
215
|
+
dependencies: this._addDependency(null)
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
const coreTx = new CoreTX(core, this.db, atom.view, [])
|
|
219
219
|
|
|
220
220
|
if (length > 0) coreTx.setHead(head)
|
|
221
|
-
coreTx.setDependency(core.dependencies[core.dependencies.length - 1])
|
|
222
221
|
|
|
223
222
|
await coreTx.flush()
|
|
224
223
|
|
|
@@ -231,7 +230,7 @@ class HypercoreStorage {
|
|
|
231
230
|
for (let i = 0; i < this.core.dependencies.length; i++) {
|
|
232
231
|
const d = this.core.dependencies[i]
|
|
233
232
|
|
|
234
|
-
if (d.length > dep.length) {
|
|
233
|
+
if (dep !== null && d.length > dep.length) {
|
|
235
234
|
deps.push({ dataPointer: d.dataPointer, length: dep.length })
|
|
236
235
|
return deps
|
|
237
236
|
}
|
|
@@ -239,7 +238,7 @@ class HypercoreStorage {
|
|
|
239
238
|
deps.push(d)
|
|
240
239
|
}
|
|
241
240
|
|
|
242
|
-
deps.push(dep)
|
|
241
|
+
if (dep !== null) deps.push(dep)
|
|
243
242
|
return deps
|
|
244
243
|
}
|
|
245
244
|
|
|
@@ -705,3 +704,17 @@ function createColumnFamily (db) {
|
|
|
705
704
|
|
|
706
705
|
return db.columnFamily(col)
|
|
707
706
|
}
|
|
707
|
+
|
|
708
|
+
function cloneCore (c) {
|
|
709
|
+
const copy = {
|
|
710
|
+
dataPointer: c.dataPointer,
|
|
711
|
+
corePointer: c.corePointer,
|
|
712
|
+
dependencies: []
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
for (const { dataPointer, length } of c.dependencies) {
|
|
716
|
+
copy.dependencies.push({ dataPointer, length })
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
return copy
|
|
720
|
+
}
|