Refactor indexer scheduling to avoid accumulating identical tasks

This commit is contained in:
Mononaut
2023-09-21 17:50:53 +01:00
parent ab8b557e73
commit 00887bc24b
3 changed files with 71 additions and 35 deletions

View File

@@ -776,9 +776,7 @@ class Blocks {
this.updateTimerProgress(timer, `saved prices for ${this.currentBlockHeight}`);
} else {
logger.debug(`Cannot save block price for ${blockExtended.height} because the price updater hasnt completed yet. Trying again in 10 seconds.`, logger.tags.mining);
setTimeout(() => {
indexer.runSingleTask('blocksPrices');
}, 10000);
indexer.scheduleSingleTask('blocksPrices', 10000);
}
// Save blocks summary for visualization if it's enabled