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

feat(iroh): add node wide default author for documents #2299

Merged
merged 25 commits into from
May 23, 2024

Conversation

Frando
Copy link
Member

@Frando Frando commented May 15, 2024

Description

This adds the notion of a node-wide default author for documents.

The default author can be retrieved via iroh.authors.default(). On persistent nodes, on first start a new author is created and its public key is saved to IROH_DATA_DIR/default-author (as a base32 string). For in-memory nodes, a new author is created.

When trying to delete the default author via iroh.authors.delete, an error is returned, stating that the default author may not be deleted.

The default author can be changed with iroh.authors.set_default.

If the default-author file is deleted manually, a new default author will be created on the next start.

Breaking Changes

  • Added iroh.authors.default(), which returns the author id of a single default author per node
  • Added iroh.authors.set_default(&self, author_id: AuthorId), which allows to set the default author for the node
  • iroh::util::path::IrohPaths enum gained new variant DefaultAuthor

Notes & open questions

There are certainly other ways to go around the interactions between the iroh-local notion of a default author and the author database in the iroh-docs store. Quoting from discord (this PR implements option B.1):

if you delete the default author with the author api, what should happen?

  • A: default author remains in place, further operations with it fail
  • A.1: on next start new default author is created automatically
  • A.2: next start fails, says "delete default_author file by hand"
  • B: deletion of default author fails.
  • B1: that's the way it is, only way to delete it is to delete default-author file by hand and restart the node
  • B2: add set_default_author rpc call
  • C: a new default author is created and set always & automatically

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@Frando Frando marked this pull request as draft May 16, 2024 10:09
@Frando Frando marked this pull request as ready for review May 16, 2024 10:09
@dignifiedquire
Copy link
Contributor

  • add set_default_author rpc call

I think this would be good to have, but we can add it later when needed

@Frando
Copy link
Member Author

Frando commented May 17, 2024

I think this would be good to have, but we can add it later when needed

added this in the most recent commit!

@Frando Frando force-pushed the feat/default-author branch 2 times, most recently from 850ad4e to d5c9dc5 Compare May 17, 2024 10:30
@Frando Frando force-pushed the feat/default-author branch 2 times, most recently from 8f708de to b200d4b Compare May 17, 2024 12:59
@Frando Frando marked this pull request as draft May 17, 2024 13:10
@Frando Frando marked this pull request as ready for review May 22, 2024 23:57
## Description

We used to store the console files (history and current author) in a
subdirectory `console` under the iroh data dir. This got lost in some
refacorings, and the console files currently are created in the iroh
data directory directly.

This is bad because the iroh data directory is a single namespace, and
we should use it cautiously.

This PR goes back to using a `console` subdirectory. Existing files are
migrated on first start of the console.

Based on #2299 because this already made the environment init functions
async.

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [ ] Self-review.
- [ ] Documentation updates if relevant.
- [ ] Tests if relevant.
- [ ] All breaking changes documented.
@dignifiedquire dignifiedquire changed the title feat: node-wide default author for documents feat(iroh): add node wide default author for documents May 23, 2024
@dignifiedquire dignifiedquire added this pull request to the merge queue May 23, 2024
Merged via the queue into main with commit c8690a2 May 23, 2024
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants