From 743e3b779094ec8770f207bfa15aae7dce180c2e Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Thu, 21 Mar 2024 14:52:04 +0100 Subject: [PATCH] feat!: Switch to SHA256 hashed CIDs, instead of rs-wnfs default Blake3, for better compatibility --- packages/nest/src/store.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/nest/src/store.ts b/packages/nest/src/store.ts index 22d6e80..65aa8ca 100644 --- a/packages/nest/src/store.ts +++ b/packages/nest/src/store.ts @@ -31,6 +31,14 @@ export function wnfs(blockstore: Blockstore): WnfsBlockStore { const decodedCid = CID.decode(cid) await blockstore.put(decodedCid, bytes) }, + + // Don't hash blocks with the rs-wnfs default Blake 3, sha256 has better support + async putBlock(bytes: Uint8Array, codec: number): Promise { + const hash = await sha256.digest(bytes) + const cid = CID.create(1, codec, hash) + await blockstore.put(cid, bytes) + return cid.bytes + }, } }