| 20 | } |
| 21 | |
| 22 | export interface IBlockchainService< |
| 23 | DS extends BaseDataSource = BaseDataSource, |
| 24 | CDS extends DS & BaseCustomDataSource = DS & BaseCustomDataSource, |
| 25 | SubQueryProject extends ISubqueryProject<IProjectNetworkConfig, DS> = ISubqueryProject<IProjectNetworkConfig, DS>, |
| 26 | SafeAPI = any, |
| 27 | LightBlock = any, |
| 28 | FullBlock = any, |
| 29 | Worker extends IBaseIndexerWorker = IBaseIndexerWorker, |
| 30 | > extends ICoreBlockchainService<DS, SubQueryProject> { |
| 31 | blockHandlerKind: string; |
| 32 | |
| 33 | // Block dispatcher service |
| 34 | fetchBlocks(blockNums: number[]): Promise<IBlock<LightBlock>[] | IBlock<FullBlock>[]>; // TODO this probably needs to change to get light block type correct |
| 35 | /* This is the worker equivalent of fetchBlocks, it provides a context to allow syncing anything between workers */ |
| 36 | fetchBlockWorker(worker: Worker, blockNum: number, context: {workers: Worker[]}): Promise<Header>; |
| 37 | |
| 38 | // /* Not all networks have a block timestamp, e.g. Shiden */ |
| 39 | // getBlockTimestamp(height: number): Promise<Date | undefined>; |
| 40 | |
| 41 | // Block dispatcher |
| 42 | /* Gets the size of the block, used to calculate a median */ |
| 43 | getBlockSize(block: IBlock): number; |
| 44 | |
| 45 | // Fetch service |
| 46 | /** |
| 47 | * The finalized header. If the chain doesn't have concrete finalization this could be a probabilistic finalization |
| 48 | * */ |
| 49 | getFinalizedHeader(): Promise<Header>; |
| 50 | /** |
| 51 | * Gets the latest height of the chain, this should be unfinalized. |
| 52 | * Or if the chain has instant finalization this would be the same as the finalized height. |
| 53 | * */ |
| 54 | getBestHeight(): Promise<number>; |
| 55 | /** |
| 56 | * The chain interval in milliseconds, if it is not consistent then provide a best estimate |
| 57 | * */ |
| 58 | getChainInterval(): Promise<number>; |
| 59 | |
| 60 | // Unfinalized blocks |
| 61 | getHeaderForHash(hash: string): Promise<Header>; |
| 62 | |
| 63 | // Dynamic Ds sevice |
| 64 | /** |
| 65 | * Applies and validates parameters to a template DS |
| 66 | * */ |
| 67 | updateDynamicDs(params: DatasourceParams, template: DS | CDS): Promise<void>; |
| 68 | |
| 69 | isCustomDs: (x: DS | CDS) => x is CDS; |
| 70 | isRuntimeDs: (x: DS | CDS) => x is DS; |
| 71 | |
| 72 | // Indexer manager |
| 73 | /** |
| 74 | * Gets an API instance to a specific height so any state queries return data as represented at that height. |
| 75 | * */ |
| 76 | getSafeApi(block: LightBlock | FullBlock): Promise<SafeAPI>; |
| 77 | } |
no outgoing calls
no test coverage detected