autobee 2.0.0-rc.2 → 2.0.0-rc.3
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 +25 -1
- package/lib/apply-calls.js +1 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -105,6 +105,7 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
105
105
|
this._hasApply = !!handlers.apply
|
|
106
106
|
this._hasUpdate = !!handlers.update
|
|
107
107
|
this._needsUpdate = false
|
|
108
|
+
this._ackRequired = false
|
|
108
109
|
this._updateLocalCore = null
|
|
109
110
|
this._host = new ApplyCalls(this)
|
|
110
111
|
this._notifyHandler = null
|
|
@@ -484,6 +485,8 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
484
485
|
// tracked across drain iteration
|
|
485
486
|
this.system.shared = null
|
|
486
487
|
|
|
488
|
+
this._ackRequired = false
|
|
489
|
+
|
|
487
490
|
const changes = this._hasUpdate ? new UpdateChanges(this) : null
|
|
488
491
|
if (changes) changes.track()
|
|
489
492
|
|
|
@@ -503,7 +506,12 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
503
506
|
break // revaluate conditions...
|
|
504
507
|
}
|
|
505
508
|
|
|
506
|
-
if (
|
|
509
|
+
if (await this._bumpPendingWriters()) {
|
|
510
|
+
this._needsUpdate = true
|
|
511
|
+
continue
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (!this._appendAck()) break
|
|
507
515
|
this._needsUpdate = true
|
|
508
516
|
}
|
|
509
517
|
|
|
@@ -744,6 +752,22 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
744
752
|
}
|
|
745
753
|
}
|
|
746
754
|
|
|
755
|
+
// append a null value node to ack writer
|
|
756
|
+
_appendAck() {
|
|
757
|
+
if (!this._ackRequired) return false
|
|
758
|
+
if (!this.writers.writable) return false
|
|
759
|
+
if (this.writers.attestations.length === 0) return false
|
|
760
|
+
|
|
761
|
+
if (this.writers.localWriter.pending !== null) return false
|
|
762
|
+
|
|
763
|
+
const links = this.system.getLinks(this.local.key)
|
|
764
|
+
const t = Math.max(this._now(), this.system.timestamp)
|
|
765
|
+
|
|
766
|
+
this.writers.appendLocal(null, t, { start: 0, end: 0 }, links, false, null)
|
|
767
|
+
this._ackRequired = false
|
|
768
|
+
return true
|
|
769
|
+
}
|
|
770
|
+
|
|
747
771
|
async _bumpPendingWriters() {
|
|
748
772
|
if (this._catchupMigratedNodes !== null) {
|
|
749
773
|
await this._bumpMigratedWriters()
|
package/lib/apply-calls.js
CHANGED