Set block/:hash/summary expiration to 1 month - Support re-org for block summaries

This commit is contained in:
nymkappa
2022-06-20 16:35:10 +02:00
parent 72a603ac37
commit aa86885e6b
7 changed files with 51 additions and 13 deletions

View File

@@ -40,6 +40,19 @@ class BlocksSummariesRepository {
return [];
}
/**
* Delete blocks from the database from blockHeight
*/
public async $deleteBlocksFrom(blockHeight: number) {
logger.info(`Delete newer blocks summary from height ${blockHeight} from the database`);
try {
await DB.query(`DELETE FROM blocks_summaries where height >= ${blockHeight}`);
} catch (e) {
logger.err('Cannot delete indexed blocks summaries. Reason: ' + (e instanceof Error ? e.message : e));
}
}
}
export default new BlocksSummariesRepository();