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

store: Streamline Store initialization #243

Open
Wondertan opened this issue Jan 28, 2025 · 0 comments
Open

store: Streamline Store initialization #243

Wondertan opened this issue Jan 28, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@Wondertan
Copy link
Member

Wondertan commented Jan 28, 2025

Currently Store has pretty convoluted initialization process. We detect that store is initialized or not basing presence of Head and allow store to be used when store wasn't Inited.

Options

1. Pass init func in Store ctor:

NewStore(..., initFn func(context.Context) (H, error))

Then during Start, the store is gonna detect if its initialized or not and execute the function accordingly, storing the initial header.

2. Remove notion of initialization entirely:

Initialization simply adds the first header to the Store, so do we really need a separate method/functionality for it, when it can be a simple Append/Put operation on the Store? Furthermore, the initial header is conceptually the same as Tail and considering future pruning this header is gonna move, so the Store doesnt really need to treat this initial header any special.

However, until we have pruning, this approach would require moving the initialization to the Syncer, so it becomes responsible for detecting lack of and fetching the first header. Although, there is nothing fundamentally wrong with this.

3. Apply strict initialization rules

  • Start throws error without prior Init
  • Store methods throw error without prior Start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants