Skip to content

Commit ca97f72

Browse files
committed
fix: make log query batch size a parameter as it can be changed on the indexed native nodes
1 parent cd92ee1 commit ca97f72

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

packages/fasset-indexer-core/src/config/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export class ConfigLoader {
7171
return minBlock == null ? undefined : parseInt(minBlock)
7272
}
7373

74+
get logQueryBatchSize(): number {
75+
const size = process.env.LOG_QUERY_BATCH_SIZE
76+
return size == null ? 28 : parseInt(size)
77+
}
78+
7479
get indexPrices(): boolean {
7580
return process.env.INDEX_PRICES === 'true'
7681
}

packages/fasset-indexer-core/src/config/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export const SLEEP_AFTER_ERROR_MS = 100
66
export const EVM_LOG_FETCH_SLEEP_MS = 30 * 1000 // collect logs every 30 seconds
77
export const EVM_STATE_UPDATE_SLEEP_MS = 60 * 1000 // collect state every one minute
88
export const EVM_BLOCK_HEIGHT_OFFSET = 10 // log collection offset from the current block height
9-
export const EVM_LOG_FETCH_SIZE = 30 // number of logs fetched from an evm chain (max is 30)
109

1110
// db settings
1211
export const MIN_DATABASE_POOL_CONNECTIONS = 2

packages/fasset-indexer-core/src/indexer/indexer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { EventScraper } from './eventlib/event-scraper'
55
import { logger } from '../logger'
66
import {
77
FIRST_UNHANDLED_EVENT_BLOCK_DB_KEY,
8-
EVM_LOG_FETCH_SIZE,
98
EVM_BLOCK_HEIGHT_OFFSET,
109
MIN_EVM_BLOCK_NUMBER_DB_KEY
1110
} from '../config/constants'
@@ -35,8 +34,8 @@ export class EventIndexer {
3534
if (endBlock === undefined || endBlock > lastBlockToHandle) {
3635
endBlock = lastBlockToHandle
3736
}
38-
for (let i = startBlock; i <= endBlock; i += EVM_LOG_FETCH_SIZE + 1) {
39-
const endLoopBlock = Math.min(endBlock, i + EVM_LOG_FETCH_SIZE)
37+
for (let i = startBlock; i <= endBlock; i += this.context.config.logQueryBatchSize + 1) {
38+
const endLoopBlock = Math.min(endBlock, i + this.context.config.logQueryBatchSize)
4039
const logs = await this.eventScraper.getLogs(i, endLoopBlock)
4140
await this.storeLogs(logs)
4241
await this.setFirstUnhandledBlock(endLoopBlock + 1)

0 commit comments

Comments
 (0)