Skip to content

Commit

Permalink
fix: add reorg count (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcar121293 authored Feb 8, 2024
1 parent e87e607 commit f9dd12d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/indexer/services/evmIndexer/evmIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { OfacComplianceService } from "../ofac"
import { getLogs } from "./evmfilter"
import { decodeLogs } from "./evmEventParser"

const BLOCK_TIME = 15000

const BLOCK_TIME = Number(process.env.BLOCK_TIME) || 15000
const BLOCK_DELAY = Number(process.env.BLOCK_DELAY) || 10
export class EvmIndexer {
private pastEventsQueryInterval = 1000
private eventsQueryInterval = 1
Expand Down Expand Up @@ -92,7 +92,7 @@ export class EvmIndexer {
while (!this.stopped) {
try {
const latestBlock = await this.provider.getBlockNumber()
if (currentBlock >= latestBlock) {
if (currentBlock + BLOCK_DELAY >= latestBlock) {
await sleep(BLOCK_TIME)
continue
}
Expand Down
6 changes: 3 additions & 3 deletions src/indexer/services/substrateIndexer/substrateIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { saveEvents, sleep } from "../../../indexer/utils/substrate"
import AccountRepository from "../../../indexer/repository/account"
import CoinMarketCapService from "../coinmarketcap/coinmarketcap.service"

const BLOCK_TIME = 12000

const BLOCK_TIME = Number(process.env.BLOCK_TIME) || 12000
const BLOCK_DELAY = Number(process.env.BLOCK_DELAY) || 10
export class SubstrateIndexer {
private domainRepository: DomainRepository
private executionRepository: ExecutionRepository
Expand Down Expand Up @@ -85,7 +85,7 @@ export class SubstrateIndexer {
try {
const latestBlock = await this.provider.rpc.chain.getBlock()
const currentBlockHash = await this.provider.rpc.chain.getBlockHash(currentBlock)
if (currentBlock >= Number(latestBlock.block.header.number)) {
if (currentBlock + BLOCK_DELAY >= Number(latestBlock.block.header.number)) {
await sleep(BLOCK_TIME)
continue
}
Expand Down

0 comments on commit f9dd12d

Please sign in to comment.