Skip to content

Persist default author in docs database - #113

Open
anchpop wants to merge 1 commit into
n0-computer:mainfrom
anchpop:default-author-in-db
Open

Persist default author in docs database#113
anchpop wants to merge 1 commit into
n0-computer:mainfrom
anchpop:default-author-in-db

Conversation

@anchpop

@anchpop anchpop commented Jul 19, 2026

Copy link
Copy Markdown

Problem

Iroh-docs currently does not support persistence on the web. To support persistence on the web, some kind of abstraction layer will be needed to hide the differences between web and native targets. To simplify that abstraction layer, iroh-docs should minimize the diversity in the ways it stores data.

If the default author were stored in the docs database itself, instead of in a sidecar file, that would be one less thing for the aforementioned future abstraction layer to think about.

Solution

Move the default author into the docs database. For existing clients, a database migration will import the default-author file on first open.

Imo, this is also just a simpler design. For example, take a look at this code that can now be deleted:

{
    let author = Author::new(&mut rand::rng());
    let author_id = author.id();
    docs_store.import_author(author).await?;
    // Make sure to write the default author to the store
    // *before* we write the default author ID file.
    // Otherwise the default author ID file is effectively a dangling reference.
    docs_store.flush_store().await?;
    self.persist(author_id).await?;
    Ok(author_id)
}

Previously, the code had to be careful to manipulate the database and the author ID in the right order for crash-correctness. This type of thing is just easier to do in a transactional database.

Breaking Changes

This is a breaking change because DefaultAuthorStorage is removed and Engine::spawn no longer takes a default author storage argument.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@n0bot n0bot Bot added this to iroh Jul 19, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Jul 19, 2026
@anchpop
anchpop force-pushed the default-author-in-db branch from 897413c to 6f00e9a Compare July 20, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚑 Needs Triage

Development

Successfully merging this pull request may close these issues.

1 participant