RPC load reduction

This commit is contained in:
Ben
2023-11-24 14:56:35 -05:00
parent 2aa0ebe587
commit b9af79978f
8 changed files with 122 additions and 22 deletions
+28
View File
@@ -0,0 +1,28 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { RpcBlockEntity } from './rpc-block.entity';
@Injectable()
export class RpcBlockService {
constructor(
@InjectRepository(RpcBlockEntity)
private rpcBlockRepository: Repository<RpcBlockEntity>
) {
}
public getBlock(blockHeight: number) {
return this.rpcBlockRepository.findOne({
where: { blockHeight }
});
}
public lockBlock(blockHeight: number, process: string) {
return this.rpcBlockRepository.save({ blockHeight, data: null, lockedBy: process });
}
public saveBlock(blockHeight: number, data: string) {
return this.rpcBlockRepository.update(blockHeight, { data })
}
}