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

Restoring pinned data from BlockstoreIDB #172

Open
pat721 opened this issue Jun 30, 2023 · 2 comments
Open

Restoring pinned data from BlockstoreIDB #172

pat721 opened this issue Jun 30, 2023 · 2 comments
Labels
kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding need/author-input Needs input from the original author need/maintainers-input Needs input from the current maintainer(s)

Comments

@pat721
Copy link

pat721 commented Jun 30, 2023

Hey everyone,

I'm having issues restoring the stored data using BlockstoreIDB.
When creating my node I'm initializing the Blockstore like so:

  let localSafedBlockstore = window.localStorage.getItem("blockstore");

  if (!localSafedBlockstore) {
    localSafedBlockstore = "blockstore-" + window.crypto.randomUUID();
    window.localStorage.setItem("blockstore", localSafedBlockstore);
  }

  const blockstore = new IDBBlockstore(localSafedBlockstore);
  await blockstore.open();

When I look into the IndexedDB in my Browser, everything is created as expected using helia.pins.add(cid).
However, when i restart my node, the contents of IDB is not pinned again so others nodes do not know about it.
Do I have to repin the data again when restarting the node? Or do I have to intialize the blockstore in a special way when restarting the node?

EDIT: I tried to repin the data when restarting the node but it doesn't change anything.

        for await (const item of helia.blockstore.getAll()) {
          const cid = await fs.addBytes(item.block);
          helia.pins.add(cid);
        }
@whizzzkid
Copy link
Contributor

Thanks for submitting this issue @pat721, can you please share a repo/gist of the complete setup? It would be easier to repro and work with.

I tried to recreate this: https://codesandbox.io/p/sandbox/helia-script-tag-forked-qh4zrr?file=%2Fsrc%2Findex.js%3A151%2C13

And indexedDB creates the entry:

Image

And then tried starting the helia node with the IDBBlockstore and didn't see the pinned content show up.

I feel this is a bug, where helia should populate and publish pins when init with a persistent blockstore.

CC: @achingbrain

@whizzzkid whizzzkid added kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding need/author-input Needs input from the original author need/maintainers-input Needs input from the current maintainer(s) labels Jul 6, 2023
@pat721
Copy link
Author

pat721 commented Jul 14, 2023

@whizzzkid Thanks for your response. I quickly hacked together an example for recreating the issue https://github.com/pat721/Helia-Test. It uses IDBBlockstore for pinning the content. I was not able to verify yet if this issue with repopulating the pins only occurs on IDBBlockstore or also on the other store implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) need/analysis Needs further analysis before proceeding need/author-input Needs input from the original author need/maintainers-input Needs input from the current maintainer(s)
Projects
No open projects
Development

No branches or pull requests

2 participants