Skip to content

Commit

Permalink
Readd heads to linearizer on restart (#53)
Browse files Browse the repository at this point in the history
* readd heads to linearizer on restart

* fix bad copy
  • Loading branch information
chm-diederichs authored Apr 13, 2023
1 parent 17d92cf commit 4142fa3
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,23 @@ module.exports = class Autobase extends ReadyResource {
this._undo(this._updates.length)

await this._cleanup()
await this._addHeads()
}

async _addHeads () {
let active = true

while (active) {
await this._ensureAll()

active = false
for (const w of this.writers) {
if (!w.next) continue
this.linearizer.addHead(w.advance())
active = true
break
}
}
}

async _advance () {
Expand All @@ -419,19 +436,7 @@ module.exports = class Autobase extends ReadyResource {
}
}

let active = true

while (active) {
await this._ensureAll()

active = false
for (const w of this.writers) {
if (!w.next) continue
this.linearizer.addHead(w.advance())
active = true
break
}
}
await this._addHeads()

const u = this.linearizer.update()
const needsRestart = u ? await this._applyUpdate(u) : false
Expand Down

0 comments on commit 4142fa3

Please sign in to comment.