44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { ChainType, BlockNumber } from '@/domain/value-objects';
|
|
|
|
export const BLOCK_CHECKPOINT_REPOSITORY = Symbol('BLOCK_CHECKPOINT_REPOSITORY');
|
|
|
|
export interface BlockCheckpointData {
|
|
chainType: string;
|
|
lastScannedBlock: bigint;
|
|
lastScannedAt: Date;
|
|
isHealthy: boolean;
|
|
lastError?: string;
|
|
}
|
|
|
|
export interface IBlockCheckpointRepository {
|
|
/**
|
|
* 获取最后扫描的区块
|
|
*/
|
|
getLastScannedBlock(chainType: ChainType): Promise<BlockNumber | null>;
|
|
|
|
/**
|
|
* 更新扫描进度
|
|
*/
|
|
updateCheckpoint(chainType: ChainType, blockNumber: BlockNumber): Promise<void>;
|
|
|
|
/**
|
|
* 记录扫描错误
|
|
*/
|
|
recordError(chainType: ChainType, error: string): Promise<void>;
|
|
|
|
/**
|
|
* 标记为健康
|
|
*/
|
|
markHealthy(chainType: ChainType): Promise<void>;
|
|
|
|
/**
|
|
* 获取检查点状态
|
|
*/
|
|
getCheckpoint(chainType: ChainType): Promise<BlockCheckpointData | null>;
|
|
|
|
/**
|
|
* 初始化检查点(如果不存在)
|
|
*/
|
|
initializeIfNotExists(chainType: ChainType, startBlock: BlockNumber): Promise<void>;
|
|
}
|