-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
807 additions
and
1,093 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
import {BaseCustomDataSource, BaseDataSource, IProjectNetworkConfig} from '@subql/types-core'; | ||
import {DatasourceParams, Header, IBlock, ISubqueryProject} from './indexer'; | ||
|
||
// TODO probably need to split this in 2 to have a worker specific subset | ||
|
||
export interface IBlockchainService< | ||
DS extends BaseDataSource = BaseDataSource, | ||
CDS extends DS & BaseCustomDataSource = BaseCustomDataSource & DS, | ||
SubQueryProject extends ISubqueryProject<IProjectNetworkConfig, DS> = ISubqueryProject<IProjectNetworkConfig, DS>, | ||
SafeAPI = any, | ||
LightBlock = any, | ||
FullBlock = any, | ||
> { | ||
/* The semver of the node */ | ||
packageVersion: string; | ||
|
||
blockHandlerKind: string; | ||
// TODO SubqueryProject methods | ||
|
||
// Block dispatcher service | ||
fetchBlocks(blockNums: number[]): Promise<IBlock<LightBlock>[] | IBlock<FullBlock>[]>; // TODO this probably needs to change to get light block type correct | ||
|
||
// Project service | ||
onProjectChange(project: SubQueryProject): Promise<void> | void; | ||
/* Not all networks have a block timestamp, e.g. Shiden */ | ||
getBlockTimestamp(height: number): Promise<Date | undefined>; | ||
|
||
// Fetch service | ||
/** | ||
* The finalized header. If the chain doesn't have concrete finalization this could be a probablilistic finalization | ||
* */ | ||
getFinalizedHeader(): Promise<Header>; | ||
/** | ||
* Gets the latest height of the chain, this should be unfinalized. | ||
* Or if the chain has instant finalization this would be the same as the finalized height. | ||
* */ | ||
getBestHeight(): Promise<number>; | ||
/** | ||
* The chain interval in milliseconds, if it is not consistent then provide a best estimate | ||
* */ | ||
getChainInterval(): Promise<number>; | ||
|
||
// Unfinalized blocks | ||
getHeaderForHash(hash: string): Promise<Header>; | ||
getHeaderForHeight(height: number): Promise<Header>; | ||
|
||
// Dynamic Ds sevice | ||
/** | ||
* Applies and validates parameters to a template DS | ||
* */ | ||
updateDynamicDs(params: DatasourceParams, template: DS | CDS): Promise<void>; | ||
|
||
isCustomDs: (x: DS | CDS) => x is CDS; | ||
isRuntimeDs: (x: DS | CDS) => x is DS; | ||
|
||
// Indexer manager | ||
/** | ||
* Gets an API instance to a specific height so any state queries return data as represented at that height. | ||
* */ | ||
getSafeApi(block: LightBlock | FullBlock): Promise<SafeAPI>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.