mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-12 18:47:30 +00:00
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:
@@ -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/"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user