Don't delete transactions when checking if the current chain is valid
This commit is contained in:
		
							parent
							
								
									44bbb472d3
								
							
						
					
					
						commit
						816fb3bf01
					
				@ -575,7 +575,6 @@ class BlocksRepository {
 | 
			
		||||
        if (blocks[idx].previous_block_hash !== blocks[idx - 1].hash) {
 | 
			
		||||
          logger.warn(`Chain divergence detected at block ${blocks[idx - 1].height}`);
 | 
			
		||||
          await this.$deleteBlocksFrom(blocks[idx - 1].height);
 | 
			
		||||
          await BlocksSummariesRepository.$deleteTransactionsFrom(blocks[idx - 1].height);
 | 
			
		||||
          await HashratesRepository.$deleteHashratesFromTimestamp(blocks[idx - 1].timestamp - 604800);
 | 
			
		||||
          await DifficultyAdjustmentsRepository.$deleteAdjustementsFromHeight(blocks[idx - 1].height);
 | 
			
		||||
          return false;
 | 
			
		||||
 | 
			
		||||
@ -82,23 +82,6 @@ class BlocksSummariesRepository {
 | 
			
		||||
    return [];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Delete blocks from the database from blockHeight
 | 
			
		||||
   */
 | 
			
		||||
  public async $deleteTransactionsFrom(blockHeight: number): Promise<void> {
 | 
			
		||||
    logger.info(`Delete blocks summaries transactions from height ${blockHeight} from the database, but keep templates`, logger.tags.mining);
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      await DB.query(`
 | 
			
		||||
        UPDATE blocks_summaries
 | 
			
		||||
        SET transactions = '[]'
 | 
			
		||||
        WHERE height >= ${blockHeight}
 | 
			
		||||
      `);
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      logger.err('Cannot delete blocks summaries transactions. Reason: ' + (e instanceof Error ? e.message : e));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Get the fee percentiles if the block has already been indexed, [] otherwise
 | 
			
		||||
   * 
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user