Skip to content

Commit

Permalink
feat!: Switch to SHA256 hashed CIDs, instead of rs-wnfs default Blake…
Browse files Browse the repository at this point in the history
…3, for better compatibility
  • Loading branch information
icidasset committed Mar 21, 2024
1 parent ca80a38 commit 743e3b7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/nest/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uint8Array> {
const hash = await sha256.digest(bytes)
const cid = CID.create(1, codec, hash)
await blockstore.put(cid, bytes)
return cid.bytes
},
}
}

Expand Down

0 comments on commit 743e3b7

Please sign in to comment.