Update fill prefetch CLI (#171)

* Update fill prefetch CLI to accept env variables

* Clean up assets before building util package

* Accomodate change in other watchers and codegen

* Add logs for debugging failing test in CI
This commit is contained in:
prathamesh0
2022-09-06 13:19:14 +05:30
committed by GitHub
parent 8af7417df6
commit 1e284bd07e
9 changed files with 36 additions and 16 deletions
+3 -1
View File
@@ -37,6 +37,8 @@
},
"scripts": {
"lint": "eslint .",
"build": "tsc"
"build": "yarn clean && tsc && yarn copy-assets",
"clean": "rm -rf ./dist",
"copy-assets": "copyfiles -u 1 src/**/*.gql dist/"
}
}
+10 -7
View File
@@ -28,8 +28,18 @@ export const fillBlocks = async (
): Promise<any> => {
let { startBlock, endBlock, prefetch = false, batchBlocks = DEFAULT_PREFETCH_BATCH_SIZE } = argv;
assert(startBlock <= endBlock, 'endBlock should be greater than or equal to startBlock');
const syncStatus = await indexer.getSyncStatus();
if (prefetch) {
if (syncStatus && startBlock <= syncStatus.chainHeadBlockNumber) {
throw new Error(`startBlock should be greater than chain head ${syncStatus.chainHeadBlockNumber}`);
}
await prefetchBlocks(indexer, blockDelayInMilliSecs, { startBlock, endBlock, batchBlocks });
return;
}
if (syncStatus) {
if (startBlock > syncStatus.chainHeadBlockNumber + 1) {
throw new Error(`Missing blocks between startBlock ${startBlock} and chainHeadBlockNumber ${syncStatus.chainHeadBlockNumber}`);
@@ -38,11 +48,6 @@ export const fillBlocks = async (
startBlock = syncStatus.chainHeadBlockNumber + 1;
}
if (prefetch) {
await prefetchBlocks(indexer, blockDelayInMilliSecs, { startBlock, endBlock, batchBlocks });
return;
}
await eventWatcher.initBlockProcessingOnCompleteHandler();
await eventWatcher.initEventProcessingOnCompleteHandler();
@@ -131,6 +136,4 @@ const prefetchBlocks = async (
process.exit(0);
}
}
console.timeEnd('time:fill#fillBlocks-process_blocks');
};