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: update storage initiation #54

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

AmeanAsad
Copy link
Contributor

Description

This PR addresses: https://github.com/filecoin-saturn/project-tracking/issues/161

The PR changes the storage interface to act as a factory function for storage. This means when we inject storage as a dependency, it returns a function which initiates the storage vs returning the storage getters, setters, etc. right away.

What this improves:

  • Any smart client functionality relies on some form of storage dependency to work. If we inject a storage dependency that is faulty, we must detect that as early as possible and replace it with a memory storage instance.
  • This allows us to catch issues with storage loading before attempting to utilize any storage functionality.

@AmeanAsad AmeanAsad requested a review from guanzo January 17, 2024 15:53
Copy link
Collaborator

@guanzo guanzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only change we need is to wrap the factory function call in a try/catch and make sure we fallback to memory storage if it errors or is missing. The rest of the changes that add inner functions aren't needed imo.

src/client.js Outdated Show resolved Hide resolved
src/storage/indexed-db-storage.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants