add cpfp progress marker to avoid reindexing early blocks

This commit is contained in:
Mononaut
2023-01-09 10:25:25 -06:00
parent c68d9d8a13
commit cb8196a27a
2 changed files with 31 additions and 1 deletions

View File

@@ -350,7 +350,7 @@ class Blocks {
let countThisRun = 0;
let timer = new Date().getTime() / 1000;
const startedAt = new Date().getTime() / 1000;
let lastHeight;
for (const block of unindexedBlocks) {
// Logging
const elapsedSeconds = Math.max(1, new Date().getTime() / 1000 - timer);
@@ -365,11 +365,13 @@ class Blocks {
await this.$indexCPFP(block.hash, block.height); // Calculate and save CPFP data for transactions in this block
lastHeight = block.height;
// Logging
count++;
countThisRun++;
}
if (count > 0) {
await cpfpRepository.$insertProgressMarker(lastHeight);
logger.notice(`CPFP indexing completed: indexed ${count} blocks`);
} else {
logger.debug(`CPFP indexing completed: indexed ${count} blocks`);