rmnvalera / java-cid-generate-hash

lib for generate CID for IPFS
MIT License
2 stars 0 forks source link

Generate CID for large files #2

Open Yangyi0011 opened 1 year ago

Yangyi0011 commented 1 year ago

Hello, I'm delighted to see the project you've written. It's been quite helpful for my needs. However, I've encountered an issue. When I use your code to calculate the CID for a large file (exceeding 256KB), the CID generated doesn't match the one obtained by directly uploading the file to IPFS. I understand that IPFS processes large files by dividing them into 256KB blocks. Have you encountered this issue as well?

Here is the code:

@Test
public void encodeV0Test() throws IOException {
    String fp = "/tmp/asset.so";
    Path path = Paths.get(fp);
    Multihash multihash = Cid.encode(path);

   // This is the CID obtained by uploading it to IPFS.
    String expected = "QmRx37BBhLbGBhAhGzGDQaQDATyjReZni9cEY5BGtApkcf";
    assertEquals("Hashes is not equals",
            expected, multihash.toString());
}

Here is result:

org.junit.ComparisonFailure: Hashes is not equals 
Expected :QmRx37BBhLbGBhAhGzGDQaQDATyjReZni9cEY5BGtApkcf
Actual   :QmUggY5zHh8U2WvRV8X1s4W2kZF6avUivQsXSX53dFcVDL

If possible, could you provide me with code that can calculate a v1 version CID for large files? I would greatly appreciate it.

rmnvalera commented 1 year ago

Sorry, I abandoned this project and don’t have time to return to it, if you want to participate in the development, then you are welcome)