mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-31 12:02:07 +00:00
Add an option to run compare CLI in batched intervals (#202)
This commit is contained in:
parent
5ffe13b723
commit
45111e68ac
@ -45,6 +45,16 @@ export const main = async (): Promise<void> => {
|
||||
demandOption: true,
|
||||
describe: 'End block number'
|
||||
},
|
||||
batchSize: {
|
||||
type: 'number',
|
||||
default: 1,
|
||||
describe: 'No. of blocks to be compared in an interval (default 1)'
|
||||
},
|
||||
interval: {
|
||||
type: 'number',
|
||||
default: 1,
|
||||
describe: 'Block interval (default 1)'
|
||||
},
|
||||
rawJson: {
|
||||
alias: 'j',
|
||||
type: 'boolean',
|
||||
@ -63,7 +73,7 @@ export const main = async (): Promise<void> => {
|
||||
}
|
||||
}).argv;
|
||||
|
||||
const { startBlock, endBlock, rawJson, queryDir, fetchIds, configFile, timeDiff } = argv;
|
||||
const { startBlock, endBlock, batchSize, interval, rawJson, queryDir, fetchIds, configFile, timeDiff } = argv;
|
||||
const config: Config = await getConfig(configFile);
|
||||
const snakeNamingStrategy = new SnakeNamingStrategy();
|
||||
const clients = await getClients(config, timeDiff, queryDir);
|
||||
@ -93,7 +103,9 @@ export const main = async (): Promise<void> => {
|
||||
});
|
||||
}
|
||||
|
||||
for (let blockNumber = startBlock; blockNumber <= endBlock; blockNumber++) {
|
||||
for (let bathchStart = startBlock; bathchStart <= endBlock; bathchStart += interval) {
|
||||
const batchEnd = bathchStart + batchSize;
|
||||
for (let blockNumber = bathchStart; blockNumber < batchEnd && blockNumber <= endBlock; blockNumber++) {
|
||||
const block = { number: blockNumber };
|
||||
const updatedEntityIds: { [entityName: string]: string[] } = {};
|
||||
const updatedEntities: Set<string> = new Set();
|
||||
@ -220,6 +232,7 @@ export const main = async (): Promise<void> => {
|
||||
|
||||
console.timeEnd(`time:compare-block-${blockNumber}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (diffFound) {
|
||||
process.exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user