autobee 2.0.0-rc.29 → 2.0.0-rc.30
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/topo.js +2 -1
- package/lib/writers.js +10 -2
- package/package.json +1 -1
package/lib/topo.js
CHANGED
|
@@ -226,7 +226,7 @@ async function inflate(auto, reorder, opts = null) {
|
|
|
226
226
|
async function getOplogBatch(undo, core, length, weight, index, opts = null) {
|
|
227
227
|
const seq = length - 1
|
|
228
228
|
const block = await core.get(seq, opts)
|
|
229
|
-
if (block === null) return null
|
|
229
|
+
if (block === null) return null // wait: false in replay helper
|
|
230
230
|
|
|
231
231
|
const oplog = encoding.decodeOplog(block)
|
|
232
232
|
const head = createNode(core, length, weight, oplog)
|
|
@@ -236,6 +236,7 @@ async function getOplogBatch(undo, core, length, weight, index, opts = null) {
|
|
|
236
236
|
if (legacy) {
|
|
237
237
|
for (let i = length - 1; i > 0; i--) {
|
|
238
238
|
const block = await core.get(i - 1, opts)
|
|
239
|
+
if (block === null) return null // wait: false in replay helper
|
|
239
240
|
const oplog = encoding.decodeOplog(block)
|
|
240
241
|
if (oplog.batch.end === 0) break
|
|
241
242
|
head.batch.start++
|
package/lib/writers.js
CHANGED
|
@@ -786,10 +786,18 @@ function createNode(core, length, weight, oplog) {
|
|
|
786
786
|
}
|
|
787
787
|
|
|
788
788
|
function finalizeNodeBatch(batch) {
|
|
789
|
-
|
|
789
|
+
// replay batches keep unreachable blocks as null holes (topo.getOplogBatch)
|
|
790
|
+
let first = null
|
|
791
|
+
for (const node of batch) {
|
|
792
|
+
if (node !== null) {
|
|
793
|
+
first = node
|
|
794
|
+
break
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
if (first === null || first.version > LEGACY_OPLOG_VERSION) return batch
|
|
790
798
|
|
|
791
799
|
for (let i = 0; i < batch.length; i++) {
|
|
792
|
-
batch[i].batch.start = i
|
|
800
|
+
if (batch[i] !== null) batch[i].batch.start = i
|
|
793
801
|
}
|
|
794
802
|
|
|
795
803
|
return batch
|