autobee 2.3.0 → 2.3.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/lib/fast-forward.js +12 -9
- package/lib/migrations.js +4 -2
- package/lib/system.js +5 -8
- package/package.json +1 -1
package/lib/fast-forward.js
CHANGED
|
@@ -167,15 +167,18 @@ module.exports = class FastForward {
|
|
|
167
167
|
// ensure local key is locally available always
|
|
168
168
|
promises.push(this.system.get(this.auto.local.key, { timeout: this.timeout }))
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
this.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
// a legacy system without the designated view migrates onto an empty view
|
|
171
|
+
if (this.system.view.length) {
|
|
172
|
+
const view = this.auto.store.get({ key: this.system.view.key, active: true })
|
|
173
|
+
this.cores.push(view)
|
|
174
|
+
|
|
175
|
+
promises.push(
|
|
176
|
+
view.get(this.system.view.length - 1, {
|
|
177
|
+
timeout: this.timeout,
|
|
178
|
+
activeRequests: this.activeRequests
|
|
179
|
+
})
|
|
180
|
+
)
|
|
181
|
+
}
|
|
179
182
|
|
|
180
183
|
for (const head of this.system.heads) {
|
|
181
184
|
promises.push(this.system.get(head.key, { timeout: this.timeout }))
|
package/lib/migrations.js
CHANGED
|
@@ -25,11 +25,13 @@ module.exports = {
|
|
|
25
25
|
coreLength
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
// a peer with a sparse copy may not hold block 0, but the recorded tail is the
|
|
29
|
+
// block it most likely has, so fetch the manifest through that when known
|
|
30
|
+
async function getCoreManifest(store, key, { timeout, wait = true, length = 0 } = {}) {
|
|
29
31
|
const core = store.get(key)
|
|
30
32
|
await core.ready()
|
|
31
33
|
try {
|
|
32
|
-
if (!core.manifest
|
|
34
|
+
if (!core.manifest) await core.get(length ? length - 1 : 0, { timeout, wait })
|
|
33
35
|
return core.manifest
|
|
34
36
|
} finally {
|
|
35
37
|
await core.close()
|
package/lib/system.js
CHANGED
|
@@ -158,7 +158,7 @@ module.exports = class Systembee {
|
|
|
158
158
|
if (!info) return EMPTY_HEAD
|
|
159
159
|
const a = this.auto
|
|
160
160
|
|
|
161
|
-
const toManifests = ({ key }) => getCoreManifest(a.store, key, { timeout })
|
|
161
|
+
const toManifests = ({ key, length }) => getCoreManifest(a.store, key, { timeout, length })
|
|
162
162
|
const promises = [...info.indexers.map(toManifests), ...info.views.map(toManifests)]
|
|
163
163
|
|
|
164
164
|
await Promise.all(promises)
|
|
@@ -168,13 +168,10 @@ module.exports = class Systembee {
|
|
|
168
168
|
// the handler only runs once the head is locked in - see auto._runMigration
|
|
169
169
|
this.migration = { views, head: this.bee.head() }
|
|
170
170
|
|
|
171
|
-
//
|
|
172
|
-
for
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return EMPTY_HEAD
|
|
171
|
+
// only the designated view may become the autobee view: the view bee decrypts
|
|
172
|
+
// with the key for its own name, so any other legacy view reads as garbage
|
|
173
|
+
const name = a.legacyViews.length ? a.legacyViews[0] : null
|
|
174
|
+
return (name && views.get(name)) || EMPTY_HEAD
|
|
178
175
|
}
|
|
179
176
|
|
|
180
177
|
bootRecord() {
|