Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check that we have all catchup nodes locally #162

Merged
merged 5 commits into from
Jun 24, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,16 @@ module.exports = class Autobase extends ReadyResource {
this._prebump = this._openPreBump()
await this._prebump

await this._catchup(this._initialHeads)
try {
await this._catchup(this._initialHeads)
} catch (err) {
safetyCatch(err)

this._initialHeads = []
await this._updateBootRecordHeads(this.system.heads)

this._warn(err)
}

await this._wakeup.ready()

Expand Down Expand Up @@ -507,7 +516,12 @@ module.exports = class Autobase extends ReadyResource {

if (length > w.end) w.end = length

const block = await w.writer.core.get(length - 1)
// we should have all nodes locally
const block = await w.writer.core.get(length - 1, { wait: false })

if (block === null) {
throw new Error('Catchup failed: local block not available')
}

for (const dep of block.node.heads) {
nodes.push(dep)
Expand Down
Loading