autobee 2.0.0-rc.0 → 2.0.0-rc.2

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 CHANGED
@@ -1145,8 +1145,11 @@ module.exports = class Autobee extends ReadyResource {
1145
1145
  this.system.bee.move(head)
1146
1146
  await this.system.reset()
1147
1147
 
1148
- // todo: binary search to find shared common tree and pass as undo
1149
- this.system.shared = { flushes: -1, view: EMPTY_HEAD, system: EMPTY_HEAD }
1148
+ this.system.shared = this.rebootTo.shared || {
1149
+ flushes: -1,
1150
+ view: EMPTY_HEAD,
1151
+ system: EMPTY_HEAD
1152
+ }
1150
1153
 
1151
1154
  // migrate is set when fast-forwarding from a legacy head
1152
1155
  if (migrate) {
package/lib/reboot.js CHANGED
@@ -86,10 +86,23 @@ module.exports = class Reboot {
86
86
  await Promise.all(promises)
87
87
  if (this.destroyed) return null
88
88
 
89
+ const shared = await this._commonAncestor()
90
+ if (this.destroyed) return null
91
+
89
92
  return {
90
93
  head: this.head,
91
94
  tip: this.tip,
92
- migrate: null
95
+ migrate: null,
96
+ shared
97
+ }
98
+ }
99
+
100
+ async _commonAncestor() {
101
+ try {
102
+ return await this.auto.system.commonAncestor(this.head)
103
+ } catch (err) {
104
+ safetyCatch(err)
105
+ return null
93
106
  }
94
107
  }
95
108
 
package/lib/system.js CHANGED
@@ -123,11 +123,13 @@ module.exports = class Systembee {
123
123
  }
124
124
 
125
125
  if (l.flushes >= r.flushes) {
126
+ if (a.done) break
126
127
  a = await hist1.next()
127
128
  if (a.value) l = getInfo(a.value)
128
129
  }
129
130
 
130
131
  if (r.flushes >= l.flushes) {
132
+ if (b.done) break
131
133
  b = await hist2.next()
132
134
  if (b.value) r = getInfo(b.value)
133
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autobee",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0-rc.2",
4
4
  "description": "Bee based autobase",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Holepunch Inc.",