Skip to content

Commit

Permalink
fix: fix chain feeder
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Ixo committed Sep 3, 2023
1 parent 9bd6277 commit cde703c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ blockRes.json
blockTx.json
bondsInfo.json

DS_Store
*.DS_Store
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/sync/sync_blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 14 additions & 3 deletions src/sync/sync_chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReturnType<typeof createQueryClient>>;
Expand All @@ -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"
Expand Down

0 comments on commit cde703c

Please sign in to comment.