diff --git a/.gitignore b/.gitignore index 0224f36..af4badb 100644 --- a/.gitignore +++ b/.gitignore @@ -76,4 +76,4 @@ blockRes.json blockTx.json bondsInfo.json -DS_Store +*.DS_Store diff --git a/Dockerfile b/Dockerfile index 91551c4..b339ae2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN yarn --pure-lockfile --production && yarn cache clean COPY . . # Generate Prisma client -RUN npx prisma generate +RUN yarn prisma:generate EXPOSE 8080 diff --git a/src/sync/sync_blocks.ts b/src/sync/sync_blocks.ts index 813a9ac..92048ba 100644 --- a/src/sync/sync_blocks.ts +++ b/src/sync/sync_blocks.ts @@ -9,7 +9,7 @@ let syncing: boolean; const logIndexTime = false; const logFetchTime = false; -const logSync100Time = false; +const logSync100Time = true; export const startSync = async () => { syncing = true; diff --git a/src/sync/sync_chain.ts b/src/sync/sync_chain.ts index 6c8c7ca..99f7666 100644 --- a/src/sync/sync_chain.ts +++ b/src/sync/sync_chain.ts @@ -4,6 +4,8 @@ import { createQueryClient, createRegistry } from "@ixo/impactxclient-sdk"; import * as Proto from "../util/proto"; import { RPC } from "../util/secrets"; import { prismaCore } from "../prisma/prisma_client"; +import { timeout } from "cron"; +import { sleep } from "../util/sleep"; export let currentChain: Chain; export let queryClient: Awaited>; @@ -18,9 +20,18 @@ export const syncChain = async () => { const chainId = res?.block?.header?.chainId || ""; if (!chainId) throw new Error("No Chain Found on RPC Endpoint"); - const coreChain = await prismaCore.chainCore.findFirst({ - where: { chainId }, - }); + let coreChain; + while (true) { + try { + coreChain = await prismaCore.chainCore.findFirst({ + where: { chainId }, + }); + break; + } catch (error) { + console.log("Waiting for Blocksync-core to start..."); + await sleep(10000); + } + } if (!coreChain) throw new Error( "No Chain Found on Blocksync-core DB for this RPC Endpoint"