Don't delete transactions when checking if the current chain is valid

This commit is contained in:
nymkappa 2023-03-31 12:22:26 +09:00
parent 44bbb472d3
commit 816fb3bf01
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 0 additions and 18 deletions

View File

@ -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;

View File

@ -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
*