[Ask For Help] How generate-car works, more specific how cid generated #9489
Unanswered
hanbu97
asked this question in
General Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I was implementing an App to send user's file directly to Filecoin network. I was obstacled at the first step, to generate the cid of the given file. Which is quite important for real world applications to use Fil as a decentralized storage. However, after some investigating about this, the only way I found to generate cid is the Lotus implemention, even for recent popolar app(boost), use Lotus's implemention directly.
I'm a rust developer. So I use fvm_ipld_car crate, I read user's file as Vec bytes and generate cid with Blake2b256.
However, in this way only when file size is tens of kb, it works and give the same cid as Lotus's(Boost's). For a very small file it gives a shorter hash and for very large file (tens of GB) the hash length is same but with different results. And for file size like 1.4MB it gives a very long hash.
It is obvious, when Lotus is generating a cid, it uses different hash method for different file size and seems do something else than directly send the file bytes to cid generator.
I noticed docs like https://docs.ipfs.tech/concepts/content-addressing/#cid-conversion . But did not explain how detailed cid and car file is generated.
In this way, I really want a clearer explanation about how Lotus generate cid and car file from a vec of bytes.
Beta Was this translation helpful? Give feedback.
All reactions