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

How to download a File via nabu and CID without knowing any of the providers ahead of time #98

Closed
Ghost-chu opened this issue Sep 24, 2024 · 3 comments

Comments

@Ghost-chu
Copy link

This is probably a stupid question... However when I following the guide in README.md to download a file by using this code:

 List<Want> wants = List.of(new Want(Cid.decode("zdpuAwfJrGYtiGFDcSV3rDpaUrqCtQZRxMjdC6Eq9PNqLqTGg")));
        Set<PeerId> retrieveFrom = Set.of(PeerId.fromBase58("QmVdFZgHnEgcedCS2G2ZNiEN59LuVrnRm7z3yXtEBv2XiF"));
        boolean addToLocal = true;
        List<HashedBlock> blocks = ipfs.getBlocks(wants, retrieveFrom, addToLocal);

I noticed that I need to know the other person's PeerID first. However I tried use the code in FindProviderTest to find any peers that provide the data, but it seems just stuck in search loop with some timeout exception and infinity sendWants tries:

**** org.peergos.protocol.bitswap.Bitswap sendWants
INFO: Send wants: 1 to [QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa, QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ, QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb, QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt] cids: [bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi]
**** org.peergos.protocol.bitswap.Bitswap sendWants
INFO: Send wants: 1 to [QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa, QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ, QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb, QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt] cids: [bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi]
**** org.peergos.protocol.bitswap.Bitswap sendWants

I tried anything that made sense, but unfortunately I still can't accomplish the simplest and most basic task - downloading files from IPFS via nabu and CID without knowing any of the providers ahead of time.

Nabu does a lot of cool work, but the lack of documentation makes it quite difficult to use.

What should I do? Is there any sample code?

@ianopolous
Copy link
Member

Nabu doesn't have a concept of a file. You could use Nabu to build such a thing relatively easily. The main thing you would need is an implementation of unixfs in dag-pb to understand how to join the blocks into a file.

When retrieving a block the peerIds are optional. If you don't supply any it will try and find providers.

@Ghost-chu
Copy link
Author

Thank you for your excellent work, I will try to find out what to do to make this.

Does Nabu have any ideas for integrating this part in the future?

@ianopolous
Copy link
Member

I think Nabu wants to stay a minimal block daemon, but others can build such a thing on top.

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

No branches or pull requests

2 participants