autobee 2.0.0-rc.28 → 2.0.0-rc.29
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 +5 -1
- package/lib/migrations.js +9 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -853,15 +853,18 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
853
853
|
|
|
854
854
|
async _bumpMigratedWriters() {
|
|
855
855
|
const opened = new Set()
|
|
856
|
+
let updated = false
|
|
856
857
|
|
|
857
858
|
for (const batch of this._catchupMigratedNodes) {
|
|
858
859
|
await this._processBatch(batch)
|
|
860
|
+
updated = true
|
|
859
861
|
for (const node of batch) {
|
|
860
862
|
if (node.from) opened.add(node.from)
|
|
861
863
|
}
|
|
862
864
|
}
|
|
863
865
|
|
|
864
866
|
for (const core of opened) await core.close()
|
|
867
|
+
return updated
|
|
865
868
|
}
|
|
866
869
|
|
|
867
870
|
// append a null value node to ack writer
|
|
@@ -899,8 +902,9 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
899
902
|
|
|
900
903
|
async _bumpPendingWriters() {
|
|
901
904
|
if (this._catchupMigratedNodes !== null) {
|
|
902
|
-
await this._bumpMigratedWriters()
|
|
905
|
+
const updated = await this._bumpMigratedWriters()
|
|
903
906
|
this._catchupMigratedNodes = null
|
|
907
|
+
if (updated) return true
|
|
904
908
|
}
|
|
905
909
|
|
|
906
910
|
// apply the best next node to keep the prefix stable
|
package/lib/migrations.js
CHANGED
|
@@ -389,7 +389,9 @@ async function getPersistedView(store, view) {
|
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
async function getCatchupHeads(session, from) {
|
|
392
|
+
const seen = new Map()
|
|
392
393
|
const nodes = []
|
|
394
|
+
|
|
393
395
|
// block 0 is the bee header, never a node
|
|
394
396
|
for (let i = Math.max(from, 1); i < session.length; i++) {
|
|
395
397
|
const node = await session.get(i, { wait: false })
|
|
@@ -400,6 +402,13 @@ async function getCatchupHeads(session, from) {
|
|
|
400
402
|
|
|
401
403
|
const { key, length } = encoding.decodeSystemWriter(entry.key, entry.value)
|
|
402
404
|
if (!length) continue
|
|
405
|
+
|
|
406
|
+
const id = b4a.toString(key, 'hex')
|
|
407
|
+
const current = seen.get(id) || 0
|
|
408
|
+
|
|
409
|
+
if (current >= length) continue
|
|
410
|
+
|
|
411
|
+
seen.set(id, length)
|
|
403
412
|
nodes.push({ key, length })
|
|
404
413
|
}
|
|
405
414
|
|