Merge pull request #1298 from nymkappa/feature/fix-hashrate-indexing-try-catch
Make sure to reset hashrates indexing flags upon error
This commit is contained in:
commit
e131ec883b
@ -108,6 +108,8 @@ class Mining {
|
|||||||
if (!blocks.blockIndexingCompleted || this.hashrateIndexingStarted) {
|
if (!blocks.blockIndexingCompleted || this.hashrateIndexingStarted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
this.hashrateIndexingStarted = true;
|
this.hashrateIndexingStarted = true;
|
||||||
|
|
||||||
logger.info(`Indexing hashrates`);
|
logger.info(`Indexing hashrates`);
|
||||||
@ -143,7 +145,7 @@ class Mining {
|
|||||||
blockStats.lastBlockHeight);
|
blockStats.lastBlockHeight);
|
||||||
|
|
||||||
if (totalIndexed > 7 && totalIndexed % 7 === 0 && !indexedTimestamp.includes(fromTimestamp + 1)) { // Save weekly pools hashrate
|
if (totalIndexed > 7 && totalIndexed % 7 === 0 && !indexedTimestamp.includes(fromTimestamp + 1)) { // Save weekly pools hashrate
|
||||||
logger.debug(`Indexing weekly hashrates for mining pools (timestamp: ${fromTimestamp})`);
|
logger.debug("Indexing weekly hashrates for mining pools");
|
||||||
let pools = await PoolsRepository.$getPoolsInfoBetween(fromTimestamp - 604800, fromTimestamp);
|
let pools = await PoolsRepository.$getPoolsInfoBetween(fromTimestamp - 604800, fromTimestamp);
|
||||||
const totalBlocks = pools.reduce((acc, pool) => acc + pool.blockCount, 0);
|
const totalBlocks = pools.reduce((acc, pool) => acc + pool.blockCount, 0);
|
||||||
pools = pools.map((pool: any) => {
|
pools = pools.map((pool: any) => {
|
||||||
@ -208,6 +210,10 @@ class Mining {
|
|||||||
this.hashrateIndexingStarted = false;
|
this.hashrateIndexingStarted = false;
|
||||||
|
|
||||||
logger.info(`Hashrates indexing completed`);
|
logger.info(`Hashrates indexing completed`);
|
||||||
|
} catch (e) {
|
||||||
|
this.hashrateIndexingStarted = false;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ class HashratesRepository {
|
|||||||
await connection.query(query);
|
await connection.query(query);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
logger.err('$saveHashrateInDatabase() error' + (e instanceof Error ? e.message : e));
|
logger.err('$saveHashrateInDatabase() error' + (e instanceof Error ? e.message : e));
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.release();
|
connection.release();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user