Update CLI to fill state to create checkpoints (#187)

* Update CLI to fill state to create checkpoints

* Accomodate changes in codegen
This commit is contained in:
prathamesh0
2022-09-16 09:23:41 +05:30
committed by GitHub
parent c2bbaa6867
commit b2cf997900
5 changed files with 43 additions and 18 deletions
@@ -63,6 +63,9 @@ export const fillState = async (
const blockHash = blocks[0].blockHash;
// Create initial state for contracts
await indexer.createInit(blockHash, blockNumber);
// Fill state for each contract in contractEntitiesMap
const contractStatePromises = Array.from(contractEntitiesMap.entries())
.map(async ([contractAddress, entities]): Promise<void> => {
@@ -90,7 +93,12 @@ export const fillState = async (
// Persist subgraph state to the DB
await indexer.dumpSubgraphState(blockHash, true);
// Create checkpoints
await indexer.processCheckpoint(blockHash);
}
// TODO: Push state to IPFS
log(`Filled state for subgraph entities in range: [${startBlock}, ${endBlock}]`);
};
@@ -419,7 +419,7 @@ export class Indexer implements IPLDIndexerInterface {
return this._baseIndexer.createStateCheckpoint(contractAddress, block, data);
}
// Method to be used by checkpoint CLI.
// Method to be used by export-state CLI.
async createCheckpoint (contractAddress: string, blockHash: string): Promise<string | undefined> {
const block = await this.getBlockProgress(blockHash);
assert(block);
@@ -427,6 +427,12 @@ export class Indexer implements IPLDIndexerInterface {
return this._baseIndexer.createCheckpoint(this, contractAddress, block);
}
// Method to be used by fill-state CLI.
async createInit (blockHash: string, blockNumber: number): Promise<void> {
// Create initial state for contracts.
await this._baseIndexer.createInit(this, blockHash, blockNumber);
}
async saveOrUpdateIPLDBlock (ipldBlock: IPLDBlock): Promise<IPLDBlock> {
return this._baseIndexer.saveOrUpdateIPLDBlock(ipldBlock);
}