Skip to content

Commit 5a3c2e5

Browse files
committed
fix(ipos): /pinFile invalid cid
1 parent 67da514 commit 5a3c2e5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

services/ipos/src/routes/pinning.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ app.post('/pinJson', vValidator('json', object({})), async (c) => {
1919
const s3 = getS3(c)
2020

2121
const content = JSON.stringify(body)
22-
const cid = (await hashOf(content)).toV0().toString()
22+
const cid = (await hashOf(content)).toString()
2323

2424
await s3.putObject({
2525
Body: content,
@@ -100,7 +100,7 @@ app.post('/pinFile', vValidator('form', pinFileRequestSchema), async (c) => {
100100
c.executionCtx.waitUntil(Promise.allSettled(promises))
101101
} else {
102102
const { content, file: f } = files[0]
103-
cid = (await hashOf(content)).toV0().toString()
103+
cid = (await hashOf(content)).toString()
104104

105105
file = f
106106
type = f.type

services/ipos/src/utils/format.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export function getObjectSize(obj: Record<string, unknown>) {
1212
}
1313

1414
export async function hashOf(content: ImportContent | string): Promise<CID> {
15-
return CID.parse(await Hash.of(content, { onlyHash: true, cidVersion: 1 }))
15+
// note: generating the hash.of from cid v1 and then converting it to cid v0 generates a wrong cid with big file sizes
16+
return CID.parse(await Hash.of(content, { onlyHash: true, cidVersion: 0 }))
1617
}
1718

1819
export function keyOf(cid: string) {

0 commit comments

Comments
 (0)