Merge pull request #1297 from nymkappa/feature/fix-hashrate-indexing
Only reset hashrate state flag after database migration - Fix weekly …
This commit is contained in:
		
						commit
						c398d164ba
					
				@ -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) => {
 | 
			
		||||
 | 
			
		||||
@ -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');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user