autobee 2.4.0 → 2.5.0

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 CHANGED
@@ -279,7 +279,7 @@ Pass `{ timeout }` to bound the reads, so a head nobody can serve fails instead
279
279
 
280
280
  Peers fast-forward onto the heads of writers they trust, so a trusted writer that has nothing to say still has to stamp its view progress into its own oplog.
281
281
 
282
- Acking does that: an empty node is appended whenever the local writer falls `ackThreshold` (default `64`) flushes behind the system.
282
+ Acking does that: an empty node is appended whenever the local writer falls `ackThreshold` (default `32`) flushes behind the system.
283
283
 
284
284
  It is enabled for exactly the writers `isTrusted` accepts. The local key is judged when the db opens, after a fast-forward, and after the local writer rotates, so a writer that becomes trusted starts acking without being told to. `setAcking` overrides it until the next of those points.
285
285
 
package/index.js CHANGED
@@ -99,9 +99,9 @@ module.exports = class Autobee extends ReadyResource {
99
99
  this.bootFrom = (fastForward && fastForward.boot) || null
100
100
 
101
101
  // conservative (default on): only fast-forward onto a head someone can serve whole
102
- this._conservativeFF = !fastForward || fastForward.conservative !== false
102
+ this._conservativeFF = !fastForward || !!fastForward.conservative
103
103
 
104
- this.trusted = new TrustedPeers(handlers)
104
+ this.trusted = new TrustedPeers(this, handlers)
105
105
 
106
106
  this.ff = null
107
107
  this.fastForwarding = null
package/lib/system.js CHANGED
@@ -48,6 +48,7 @@ module.exports = class Systembee {
48
48
  this.updates = new Map()
49
49
  this.writers = new Map()
50
50
  this.encrypted = opts.encrypted === true
51
+ this.indexers = null
51
52
  this.promotions = new Promotions(this.bee)
52
53
  }
53
54
 
@@ -143,6 +144,9 @@ module.exports = class Systembee {
143
144
  // ~~~ good enough estimation
144
145
  this.flushes = Math.floor(this.bee.core.length / 2)
145
146
  this.view = await this._migrate(info, { timeout })
147
+ this.indexers = info ? info.indexers : null
148
+ } else {
149
+ this.indexers = null
146
150
  }
147
151
 
148
152
  this.updates.clear()
package/lib/trusted.js CHANGED
@@ -1,9 +1,10 @@
1
1
  const b4a = require('b4a')
2
2
 
3
3
  class TrustedPeers {
4
- constructor(hooks) {
4
+ constructor(auto, hooks) {
5
5
  this.trusted = new Map()
6
6
  this.pending = new Map()
7
+ this.auto = auto
7
8
  this.hooks = hooks
8
9
  }
9
10
 
@@ -11,6 +12,18 @@ class TrustedPeers {
11
12
  const hex = b4a.toString(key, 'hex')
12
13
  if (this.trusted.get(hex)) return true
13
14
 
15
+ // bootstrap
16
+ if (this.auto.system.isGenesis() && b4a.equals(key, this.auto.key)) {
17
+ return true
18
+ }
19
+
20
+ // legacy handling
21
+ if (this.auto.system.indexers) {
22
+ for (const idx of this.auto.system.indexers) {
23
+ if (b4a.equals(key, idx.key)) return true
24
+ }
25
+ }
26
+
14
27
  let promise = this.pending.get(hex)
15
28
  if (promise) return promise
16
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autobee",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Bee based autobase",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Holepunch Inc.",