Skip to content

Commit

Permalink
also wakeup writer deps when encountered
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Sep 20, 2024
1 parent 4a791df commit 70ec18d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1358,8 +1358,12 @@ module.exports = class Autobase extends ReadyResource {
}

async _wakeupWriter (key) {
const w = await this._getWriterByKey(key, -1, 0, true, false, null)
if (w === null || w.isBootstrap === false) return
this._ensureWakeup(await this._getWriterByKey(key, -1, 0, true, false, null))
}

// ensure wakeup on an existing writer (the writer calls this in addition to above)
_ensureWakeup (w) {
if (w === null || w.isBootstrap === true) return
if (!w.core.opened) w.core.ready()
w.setBootstrap(true) // even if turn false at end of drain, hypercore makes them linger a bit so no churn
this._bootstrapWriters.push(w)
Expand Down
1 change: 1 addition & 0 deletions lib/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ module.exports = class Writer extends ReadyResource {
const headWriter = await this.base._getWriterByKey(rawHead.key, -1, rawHead.length, true, false, null)

if (headWriter !== this && (headWriter === null || headWriter.length < rawHead.length)) {
this.base._ensureWakeup(headWriter)
return false
}

Expand Down

0 comments on commit 70ec18d

Please sign in to comment.