autobee 2.7.0 → 2.7.1
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/README.md +5 -1
- package/index.js +6 -4
- package/lib/fast-forward.js +7 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -256,13 +256,17 @@ Return the oplog head you most recently vouched for, given the `target` view bei
|
|
|
256
256
|
|
|
257
257
|
Called at flush time to stamp your own oplog (with your view as `target` and a `null` reference), and again per candidate during discovery.
|
|
258
258
|
|
|
259
|
+
During discovery `target` is a view opened for the candidate, and reads through it carry the fast-forward's timeout. Anything else the hook awaits is unbounded, so if it reaches beyond that view, put a timeout on it: the candidate waits on the hook, and so does closing it.
|
|
260
|
+
|
|
259
261
|
#### `warmup(view)`
|
|
260
262
|
|
|
261
263
|
Prepare a candidate `view` before the fast-forward onto it is applied.
|
|
262
264
|
|
|
263
265
|
Called as soon as the candidate's view head is known, and runs alongside the block downloads the fast-forward is already doing rather than after them. Throw or reject to reject the candidate: the fast-forward is abandoned and the usual apply path catches up instead.
|
|
264
266
|
|
|
265
|
-
`view` is opened and closed through the `open` and `close` handlers, so don't build or close a db of your own.
|
|
267
|
+
`view` is opened and closed through the `open` and `close` handlers, so don't build or close a db of your own. Reads through it carry the fast-forward's timeout, so a warmup that needs blocks nobody serves fails the candidate instead of hanging.
|
|
268
|
+
|
|
269
|
+
Only reads through `view` are bounded. Anything else the handler awaits, such as other cores or your own network calls, is up to you to time out: the fast-forward waits on the handler, and an abandoned candidate cannot finish closing until it returns.
|
|
266
270
|
|
|
267
271
|
#### `fastForward.boot`
|
|
268
272
|
|
package/index.js
CHANGED
|
@@ -437,15 +437,17 @@ module.exports = class Autobee extends ReadyResource {
|
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
// the view an oplog head points at, opened and closed through the handlers
|
|
440
|
-
openViewAt(oplog) {
|
|
440
|
+
openViewAt(oplog, { timeout } = {}) {
|
|
441
441
|
const v = oplog.op.views.view
|
|
442
442
|
if (!v) return null
|
|
443
443
|
|
|
444
|
-
return this.openView({ key: v.key, length: v.start + v.length })
|
|
444
|
+
return this.openView({ key: v.key, length: v.start + v.length }, { timeout })
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
|
|
448
|
-
|
|
447
|
+
// timeout bounds every hypercore read done through the view, defaults to the main bee's
|
|
448
|
+
openView(head, { timeout } = {}) {
|
|
449
|
+
const bee = this.bee.checkout({ key: head.key, length: head.length, timeout })
|
|
450
|
+
return new ApplyView(bee, this)
|
|
449
451
|
}
|
|
450
452
|
|
|
451
453
|
openCore(key) {
|
package/lib/fast-forward.js
CHANGED
|
@@ -56,7 +56,9 @@ class FastForward {
|
|
|
56
56
|
return null
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
return new FastForward(auto, batchToHead(verified.op.views.system)
|
|
59
|
+
return new FastForward(auto, batchToHead(verified.op.views.system), {
|
|
60
|
+
timeout: timeout || DEFAULT_OP_TIMEOUT
|
|
61
|
+
})
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
static async fromHeads(auto, heads, { force = false, timeout = 0 } = {}) {
|
|
@@ -107,7 +109,7 @@ class FastForward {
|
|
|
107
109
|
candidates.sort((a, b) => b.op.views.flushes - a.op.views.flushes)
|
|
108
110
|
|
|
109
111
|
for (const res of candidates) {
|
|
110
|
-
const trusted = await FastForward.mostRecentTrusted(auto, res, reference)
|
|
112
|
+
const trusted = await FastForward.mostRecentTrusted(auto, res, reference, timeout)
|
|
111
113
|
if (trusted === null) continue
|
|
112
114
|
if (auto.fastForwarding || auto.fastForwardTo) return null
|
|
113
115
|
|
|
@@ -130,8 +132,8 @@ class FastForward {
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
static async mostRecentTrusted(auto, head, reference) {
|
|
134
|
-
const opened = auto.openViewAt(head)
|
|
135
|
+
static async mostRecentTrusted(auto, head, reference, timeout) {
|
|
136
|
+
const opened = auto.openViewAt(head, { timeout })
|
|
135
137
|
if (opened === null) return null
|
|
136
138
|
|
|
137
139
|
try {
|
|
@@ -206,7 +208,7 @@ class FastForward {
|
|
|
206
208
|
_startWarmup() {
|
|
207
209
|
if (!this.auto._warmup || !this.system.view.length) return false
|
|
208
210
|
|
|
209
|
-
this.warmupView = this.auto.openView(this.system.view)
|
|
211
|
+
this.warmupView = this.auto.openView(this.system.view, { timeout: this.timeout })
|
|
210
212
|
|
|
211
213
|
// ensure thenable
|
|
212
214
|
this.warmup = Promise.resolve(this.auto._warmup(this.warmupView.view))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autobee",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Bee based autobase",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Holepunch Inc.",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"autobee-wakeup": "^1.1.3",
|
|
28
28
|
"b4a": "^1.8.0",
|
|
29
29
|
"compact-encoding": "^3.3.0",
|
|
30
|
-
"hyperbee2": "^2.
|
|
30
|
+
"hyperbee2": "^2.16.0",
|
|
31
31
|
"hypercore": "^11.33.2",
|
|
32
32
|
"hypercore-id-encoding": "^1.3.0",
|
|
33
33
|
"hyperschema": "^1.20.1",
|