Add an option to run compare CLI in batched intervals (#202)

This commit is contained in:
prathamesh0 2022-10-17 01:37:21 -05:00 committed by GitHub
parent 5ffe13b723
commit 45111e68ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);