Refactor import-state CLI to cli package (#250)

* Remove unnecessary upstream config arg to event watcher

* Initialize event watcher in CLI package

* Refactor import-state CLI to cli package
This commit is contained in:
prathamesh0
2022-11-22 16:41:15 +05:30
committed by GitHub
parent 6622d0874e
commit 6737ec756c
37 changed files with 369 additions and 513 deletions
+3 -4
View File
@@ -11,8 +11,7 @@ import {
EventWatcher as BaseEventWatcher,
EventWatcherInterface,
QUEUE_BLOCK_PROCESSING,
QUEUE_EVENT_PROCESSING,
UpstreamConfig
QUEUE_EVENT_PROCESSING
} from '@cerc-io/util';
import { Indexer } from './indexer';
@@ -25,7 +24,7 @@ export class EventWatcher implements EventWatcherInterface {
_pubsub: PubSub
_jobQueue: JobQueue
constructor (upstreamConfig: UpstreamConfig, ethClient: EthClient, indexer: Indexer, pubsub: PubSub, jobQueue: JobQueue) {
constructor (ethClient: EthClient, indexer: Indexer, pubsub: PubSub, jobQueue: JobQueue) {
assert(ethClient);
assert(indexer);
@@ -33,7 +32,7 @@ export class EventWatcher implements EventWatcherInterface {
this._indexer = indexer;
this._pubsub = pubsub;
this._jobQueue = jobQueue;
this._baseEventWatcher = new BaseEventWatcher(upstreamConfig, this._ethClient, this._indexer, this._pubsub, this._jobQueue);
this._baseEventWatcher = new BaseEventWatcher(this._ethClient, this._indexer, this._pubsub, this._jobQueue);
}
getEventIterator (): AsyncIterator<any> {
+1 -1
View File
@@ -76,7 +76,7 @@ export const main = async (): Promise<any> => {
const indexer = new Indexer(config.server, db, { ethClient }, ethProvider, jobQueue);
const eventWatcher = new EventWatcher(config.upstream, ethClient, indexer, pubsub, jobQueue);
const eventWatcher = new EventWatcher(ethClient, indexer, pubsub, jobQueue);
await fillBlocks(jobQueue, indexer, eventWatcher, jobQueueConfig.blockDelayInMilliSecs, argv);
};
+21 -1
View File
@@ -12,7 +12,19 @@ import { BaseProvider } from '@ethersproject/providers';
import { EthClient } from '@cerc-io/ipld-eth-client';
import { MappingKey, StorageLayout } from '@cerc-io/solidity-mapper';
import { IndexerInterface, Indexer as BaseIndexer, ValueResult, JobQueue, Where, QueryOptions, ServerConfig, StateStatus, DatabaseInterface, Clients } from '@cerc-io/util';
import {
IndexerInterface,
Indexer as BaseIndexer,
ValueResult,
JobQueue,
Where,
QueryOptions,
ServerConfig,
StateStatus,
DatabaseInterface,
Clients,
StateKind
} from '@cerc-io/util';
import { Database, ENTITIES } from './database';
import { Event } from './entity/Event';
@@ -273,6 +285,14 @@ export class Indexer implements IndexerInterface {
return undefined;
}
async saveOrUpdateState (state: State): Promise<State> {
return {} as State;
}
async removeStates (blockNumber: number, kind: StateKind): Promise<void> {
// TODO Implement
}
getStateData (state: State): any {
return this._baseIndexer.getStateData(state);
}
+1 -1
View File
@@ -57,7 +57,7 @@ export const main = async (): Promise<any> => {
const indexer = new Indexer(config.server, db, { ethClient }, ethProvider, jobQueue);
await indexer.init();
const eventWatcher = new EventWatcher(config.upstream, ethClient, indexer, pubsub, jobQueue);
const eventWatcher = new EventWatcher(ethClient, indexer, pubsub, jobQueue);
if (watcherKind === KIND_ACTIVE) {
await jobQueue.start();