separate home graph into it's own table

This commit is contained in:
Ben Wilson
2024-01-16 19:37:29 -05:00
parent bbc14e2272
commit 6bc42defef
8 changed files with 173 additions and 5 deletions
+15
View File
@@ -25,4 +25,19 @@ export class RpcBlockService {
public saveBlock(blockHeight: number, data: string) {
return this.rpcBlockRepository.update(blockHeight, { data })
}
public async deleteOldBlocks() {
const result = await this.rpcBlockRepository.createQueryBuilder('entity')
.select('MAX(entity.blockHeight)', 'maxNumber')
.getRawOne();
const newestBlock = result ? result.maxNumber : null;
await this.rpcBlockRepository.createQueryBuilder()
.delete()
.where('"blockHeight" < :newestBlock', { newestBlock })
.execute();
return;
}
}