mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
RPC load reduction
This commit is contained in:
@@ -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 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user