diff --git a/src/indexer/bootstrap.ts b/src/indexer/bootstrap.ts index 84cb5c2d10ca7d65d86552c00bbdbe3bb4b02bf5..1c477173d85524b3622624da44dbf0aa70a5aa98 100644 --- a/src/indexer/bootstrap.ts +++ b/src/indexer/bootstrap.ts @@ -25,7 +25,7 @@ export async function initHistIfNull(cid: CID): Promise<void> { timestamp: Date.now() } const firstHistCID = await kubo.dag.put(firstHist) - kubo.name + await kubo.name .publish(firstHistCID, DD_TAMT_HIST_OPT) .then(() => console.log('initialize history to ' + DD_TAMT_HIST_OPT.key)) } diff --git a/src/indexer/database.ts b/src/indexer/database.ts index dffc32238b274f63b8358d37b08255a43a85cde6..f2dfd73adfc7909bb204a3d996ecd4182f40d0e1 100644 --- a/src/indexer/database.ts +++ b/src/indexer/database.ts @@ -29,7 +29,7 @@ interface QueryBuilder { paramBuilder: (irCID: CID, ir: IndexRequest, dataCID: CID, data: any) => any[] } const defaultDataGetter = (dataCID: CID) => kubo.dag.get(dataCID).then((d) => d.value) -const defaultDataTransform = (_a: CID, _b: IndexRequest, _c: CID, d: any) => d +const defaultDataTransform = (_a: CID, _b: IndexRequest, _c: CID, d: any) => Promise.resolve(d) // initialize client const { Client } = pg @@ -142,7 +142,7 @@ const cesiumPlusProfileRaw: QueryBuilder = { const fileCandidate = { content: new Uint8Array(buffer) } // optimization: compute the hash locally without submitting it to kubo // difficulty: check that the hash is the same - cplus.avatar = (await kubo.add(fileCandidate, { onlyHash: true })).cid + cplus.avatar = (await kubo.add(fileCandidate)).cid } return cplus }, @@ -204,26 +204,26 @@ async function handleIrWithNonNullData<T>(irCID: CID, ir: IndexRequest, q: Query export async function handleInsertRequest(irCID: CID, ir: IndexRequest) { console.log('💾 indexing ' + irCID) - switch (ir.kind.toString()) { + switch (ir.kind) { // insert cesium plus profile - case CESIUM_PLUS_PROFILE_INSERT.toString(): + case CESIUM_PLUS_PROFILE_INSERT: handleIrWithNonNullData<CplusProfile>(irCID, ir, cesiumPlusProfile) break // insert cesium plus import - case CESIUM_PLUS_PROFILE_IMPORT.toString(): + case CESIUM_PLUS_PROFILE_IMPORT: // transform base58 pubkey to ss58 address with gdev prefix ir.pubkey = base58ToSS58(ir.pubkey, GDEV_PREFIX) handleIrWithNonNullData<CplusProfile>(irCID, ir, cesiumPlusProfileRaw) break // delete cesium plus profile - case CESIUM_PLUS_PROFILE_DELETE.toString(): + case CESIUM_PLUS_PROFILE_DELETE: await client.query(`DELETE FROM profiles WHERE pubkey = $1;`, [ir.pubkey]) break // insert transaction comment - case TRANSACTION_COMMENT.toString(): + case TRANSACTION_COMMENT: handleIrWithNonNullData<TxComment>(irCID, ir, txComment) break diff --git a/src/scripts/cesium-plus-import.ts b/src/scripts/cesium-plus-import.ts index 0682028a883f2e67482cf973e668724fb5956a13..642a21f44405f846deb433c392acd5ca2f38986b 100644 --- a/src/scripts/cesium-plus-import.ts +++ b/src/scripts/cesium-plus-import.ts @@ -130,5 +130,5 @@ async function importAllCplusToAMT() { // 3 minutes // import by batch and logs successive cids -importAllCplusToAMT() +// importAllCplusToAMT() // → bafyreih4jspnqnsd4o3sdqv7c765uyylhtlh5majjw6aq6clilkq7tmqey \ No newline at end of file