diff --git a/backend/src/api/mining.ts b/backend/src/api/mining.ts index c0970bf24..09dec32a2 100644 --- a/backend/src/api/mining.ts +++ b/backend/src/api/mining.ts @@ -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) => { diff --git a/backend/src/index.ts b/backend/src/index.ts index 4305d6dac..c3de6fd69 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -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');