From e61bd5177a01fefba894b842a3afed9836f27db2 Mon Sep 17 00:00:00 2001 From: nabarun Date: Wed, 23 Nov 2022 11:12:02 +0530 Subject: [PATCH] Prune optional methods in indexer and database interfaces --- packages/erc20-watcher/src/database.ts | 6 ++++++ packages/erc20-watcher/src/indexer.ts | 14 ++++++++++++++ packages/uni-watcher/src/database.ts | 6 ++++++ packages/uni-watcher/src/indexer.ts | 10 ++++++++++ 4 files changed, 36 insertions(+) diff --git a/packages/erc20-watcher/src/database.ts b/packages/erc20-watcher/src/database.ts index 7d1df13a..9556d7e6 100644 --- a/packages/erc20-watcher/src/database.ts +++ b/packages/erc20-watcher/src/database.ts @@ -83,6 +83,12 @@ export class Database implements DatabaseInterface { await this._baseDatabase.removeStates(repo, blockNumber, kind); } + async removeStatesAfterBlock (dbTx: QueryRunner, blockNumber: number): Promise { + const repo = dbTx.manager.getRepository(State); + + await this._baseDatabase.removeStatesAfterBlock(repo, blockNumber); + } + async getStateSyncStatus (): Promise { const repo = this._conn.getRepository(StateSyncStatus); diff --git a/packages/erc20-watcher/src/indexer.ts b/packages/erc20-watcher/src/indexer.ts index a78ffd8c..74e385b6 100644 --- a/packages/erc20-watcher/src/indexer.ts +++ b/packages/erc20-watcher/src/indexer.ts @@ -349,6 +349,16 @@ export class Indexer implements IndexerInterface { // TODO Implement } + async processInitialState (contractAddress: string, blockHash: string): Promise { + // TODO: Call initial state hook. + return undefined; + } + + async processStateCheckpoint (contractAddress: string, blockHash: string): Promise { + // TODO: Call checkpoint hook. + return false; + } + async processCheckpoint (blockHash: string): Promise { // TODO Implement } @@ -463,6 +473,10 @@ export class Indexer implements IndexerInterface { this._baseIndexer.updateStateStatusMap(address, stateStatus); } + cacheContract (contract: Contract): void { + return this._baseIndexer.cacheContract(contract); + } + async saveEventEntity (dbEvent: Event): Promise { return this._baseIndexer.saveEventEntity(dbEvent); } diff --git a/packages/uni-watcher/src/database.ts b/packages/uni-watcher/src/database.ts index 8d80b7f3..7bddca27 100644 --- a/packages/uni-watcher/src/database.ts +++ b/packages/uni-watcher/src/database.ts @@ -78,6 +78,12 @@ export class Database implements DatabaseInterface { await this._baseDatabase.removeStates(repo, blockNumber, kind); } + async removeStatesAfterBlock (dbTx: QueryRunner, blockNumber: number): Promise { + const repo = dbTx.manager.getRepository(State); + + await this._baseDatabase.removeStatesAfterBlock(repo, blockNumber); + } + async getStateSyncStatus (): Promise { const repo = this._conn.getRepository(StateSyncStatus); diff --git a/packages/uni-watcher/src/indexer.ts b/packages/uni-watcher/src/indexer.ts index 85950fc6..38de0558 100644 --- a/packages/uni-watcher/src/indexer.ts +++ b/packages/uni-watcher/src/indexer.ts @@ -130,6 +130,16 @@ export class Indexer implements IndexerInterface { // TODO Implement } + async processInitialState (contractAddress: string, blockHash: string): Promise { + // TODO: Call initial state hook. + return undefined; + } + + async processStateCheckpoint (contractAddress: string, blockHash: string): Promise { + // TODO: Call checkpoint hook. + return false; + } + async processCheckpoint (blockHash: string): Promise { // TODO Implement }