hypercore-storage 1.7.1 → 1.8.0
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 +24 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -101,6 +101,30 @@ class HypercoreStorage {
|
|
|
101
101
|
return null
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
updateSnapshotHead (dep) {
|
|
105
|
+
const deps = this.core.dependencies
|
|
106
|
+
|
|
107
|
+
for (let i = deps.length - 1; i >= 0; i--) {
|
|
108
|
+
const d = deps[i]
|
|
109
|
+
|
|
110
|
+
if (d.dataPointer !== dep.dataPointer) continue
|
|
111
|
+
|
|
112
|
+
// check if nothing changed
|
|
113
|
+
if (d.length === dep.length && i === deps.length - 1) return
|
|
114
|
+
|
|
115
|
+
this.core = {
|
|
116
|
+
corePointer: this.core.corePointer,
|
|
117
|
+
dataPointer: this.core.dataPointer,
|
|
118
|
+
dependencies: deps.slice(0, i + 1)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
this.core.dependencies[i] = {
|
|
122
|
+
dataPointer: dep.dataPointer,
|
|
123
|
+
length: dep.length
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
104
128
|
// TODO: this might have to be async if the dependents have changed, but prop ok for now
|
|
105
129
|
updateDependencyLength (length, truncated) {
|
|
106
130
|
const deps = this.core.dependencies
|