hypercore-storage 1.7.1 → 1.8.1
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 +29 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -101,6 +101,35 @@ class HypercoreStorage {
|
|
|
101
101
|
return null
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
setDependencyHead (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
|
+
this.core.dependencies = [{
|
|
128
|
+
dataPointer: dep.dataPointer,
|
|
129
|
+
length: dep.length
|
|
130
|
+
}]
|
|
131
|
+
}
|
|
132
|
+
|
|
104
133
|
// TODO: this might have to be async if the dependents have changed, but prop ok for now
|
|
105
134
|
updateDependencyLength (length, truncated) {
|
|
106
135
|
const deps = this.core.dependencies
|