autobee 2.0.0-rc.16 → 2.0.0-rc.17
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 +6 -3
- package/lib/writers.js +8 -4
- package/package.json +1 -1
package/lib/topo.js
CHANGED
|
@@ -308,7 +308,9 @@ function getLocalBatch(undo, writer, length, weight, index) {
|
|
|
308
308
|
|
|
309
309
|
if (length > writer.core.length) {
|
|
310
310
|
if (!writer.pending) {
|
|
311
|
-
throw new Error(
|
|
311
|
+
throw new Error(
|
|
312
|
+
`No local nodes: looking for ${length}, found ${writer.core.length}@${writer.core.id}`
|
|
313
|
+
)
|
|
312
314
|
}
|
|
313
315
|
|
|
314
316
|
let i = 0
|
|
@@ -318,9 +320,10 @@ function getLocalBatch(undo, writer, length, weight, index) {
|
|
|
318
320
|
}
|
|
319
321
|
|
|
320
322
|
const head = writer.pending[i]
|
|
323
|
+
const headBatch = head.batch || { start: 0, end: 0 }
|
|
321
324
|
|
|
322
|
-
const start = i -
|
|
323
|
-
const end = i +
|
|
325
|
+
const start = i - headBatch.start
|
|
326
|
+
const end = i + headBatch.end + 1 // include head
|
|
324
327
|
|
|
325
328
|
const batch = writer.pending.slice(start, end)
|
|
326
329
|
return { undo, batch, index }
|
package/lib/writers.js
CHANGED
|
@@ -652,8 +652,8 @@ class Writer {
|
|
|
652
652
|
this.processed = 0
|
|
653
653
|
}
|
|
654
654
|
|
|
655
|
-
flush(views, queued, trusted) {
|
|
656
|
-
if (this.pending === null || this.processed === 0) return
|
|
655
|
+
async flush(views, queued, trusted) {
|
|
656
|
+
if (this.pending === null || this.processed === 0) return
|
|
657
657
|
|
|
658
658
|
const head = this.pending[this.processed - 1]
|
|
659
659
|
head.views = views
|
|
@@ -681,8 +681,12 @@ class Writer {
|
|
|
681
681
|
for (let i = 0; i < this.processed; i++) {
|
|
682
682
|
buffers.push(encoding.encodeOplog(this.pending[i]))
|
|
683
683
|
}
|
|
684
|
-
|
|
685
|
-
|
|
684
|
+
|
|
685
|
+
try {
|
|
686
|
+
await this.core.append(buffers)
|
|
687
|
+
} finally {
|
|
688
|
+
this.clear()
|
|
689
|
+
}
|
|
686
690
|
}
|
|
687
691
|
}
|
|
688
692
|
|