autobee 2.0.0-rc.11 → 2.0.0-rc.12
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 +12 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -76,8 +76,13 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
76
76
|
this.writers = null
|
|
77
77
|
this.bumping = 0
|
|
78
78
|
|
|
79
|
+
const fastForward = handlers.fastForward || {}
|
|
80
|
+
|
|
79
81
|
// system head to boot from: migrates or fast-forwards depending on its version
|
|
80
|
-
this.bootFrom =
|
|
82
|
+
this.bootFrom = fastForward.boot || null
|
|
83
|
+
|
|
84
|
+
// conservative (default on): only fast-forward onto a head someone can serve whole
|
|
85
|
+
this._conservativeFF = fastForward.conservative !== false
|
|
81
86
|
|
|
82
87
|
this.reboot = null
|
|
83
88
|
this.rebooting = null
|
|
@@ -605,6 +610,9 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
605
610
|
const target = length >= 0 ? length : core.length
|
|
606
611
|
if (target === 0) return null
|
|
607
612
|
|
|
613
|
+
// conservative: only proceed when a connected peer can serve the head whole
|
|
614
|
+
if (opts && opts.conservative && core.remoteContiguousLength < target) return null
|
|
615
|
+
|
|
608
616
|
const buf = await core.get(target - 1, opts)
|
|
609
617
|
if (buf === null) return null
|
|
610
618
|
|
|
@@ -1159,7 +1167,9 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
1159
1167
|
}
|
|
1160
1168
|
|
|
1161
1169
|
async _rebootFromHead(head, trusted, { force = false, wait = true } = {}) {
|
|
1162
|
-
const
|
|
1170
|
+
const conservative = !force && this._conservativeFF
|
|
1171
|
+
|
|
1172
|
+
const oplog = await this._getOplog(head.key, head.length, { conservative })
|
|
1163
1173
|
if (!oplog) return null
|
|
1164
1174
|
|
|
1165
1175
|
const verified = trusted ? await this._getOplog(trusted.key, trusted.length) : oplog
|