Only reset hashrate state flag after database migration - Fix weekly hashrate indexing bug

This commit is contained in:
nymkappa 2022-03-05 13:54:07 +01:00
parent 5f19b6dd07
commit 5f6c1c6ccf
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 3 additions and 3 deletions

View File

@ -142,8 +142,8 @@ class Mining {
lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
blockStats.lastBlockHeight);
if (totalIndexed % 7 === 0 && !indexedTimestamp.includes(fromTimestamp + 1)) { // Save weekly pools hashrate
logger.debug("Indexing weekly hashrates for mining pools");
if (totalIndexed > 7 && totalIndexed % 7 === 0 && !indexedTimestamp.includes(fromTimestamp + 1)) { // Save weekly pools hashrate
logger.debug(`Indexing weekly hashrates for mining pools (timestamp: ${fromTimestamp})`);
let pools = await PoolsRepository.$getPoolsInfoBetween(fromTimestamp - 604800, fromTimestamp);
const totalBlocks = pools.reduce((acc, pool) => acc + pool.blockCount, 0);
pools = pools.map((pool: any) => {

View File

@ -96,8 +96,8 @@ class Server {
await Common.sleep(5000);
await databaseMigration.$truncateIndexedData(tables);
}
await this.$resetHashratesIndexingState();
await databaseMigration.$initializeOrMigrateDatabase();
await this.$resetHashratesIndexingState();
await poolsParser.migratePoolsJson();
} catch (e) {
throw new Error(e instanceof Error ? e.message : 'Error');