Use postgraphile client to fetch blocks

This commit is contained in:
2021-12-28 16:08:04 +05:30
committed by nabarun
parent bb1345c696
commit 62521d7ccc
9 changed files with 13 additions and 7 deletions
@@ -17,7 +17,7 @@ import {
QUEUE_HOOKS,
QUEUE_IPFS,
UNKNOWN_EVENT_NAME,
UpstreamConfig
UpstreamConfig,
JOB_KIND_PRUNE
} from '@vulcanize/util';
@@ -62,7 +62,7 @@ export const main = async (): Promise<any> => {
const eventWatcher = new EventWatcher(config.upstream, ethClient, postgraphileClient, indexer, pubsub, jobQueue);
await fillBlocks(jobQueue, indexer, postgraphileClient, eventWatcher, argv);
await fillBlocks(jobQueue, indexer, postgraphileClient, eventWatcher, config.upstream.ethServer.blockDelayInMilliSecs, argv);
};
main().catch(err => {
@@ -60,7 +60,7 @@ export const main = async (): Promise<any> => {
const jobQueue = new JobQueue({ dbConnectionString, maxCompletionLag: maxCompletionLagInSecs });
await jobQueue.start();
const eventWatcher = new EventWatcher(ethClient, indexer, pubsub, jobQueue);
const eventWatcher = new EventWatcher(config.upstream, ethClient, postgraphileClient, indexer, pubsub, jobQueue);
// Import data.
const importFilePath = path.resolve(argv.importFile);
@@ -71,8 +71,9 @@ export const main = async (): Promise<any> => {
await fillBlocks(
jobQueue,
indexer,
ethClient,
postgraphileClient,
eventWatcher,
config.upstream.ethServer.blockDelayInMilliSecs,
{
startBlock: importData.snapshotBlock.blockNumber,
endBlock: importData.snapshotBlock.blockNumber
@@ -89,11 +89,13 @@ export class Indexer implements IndexerInterface {
constructor (serverConfig: ServerConfig, db: Database, ethClient: EthClient, postgraphileClient: EthClient, ethProvider: BaseProvider) {
assert(db);
assert(ethClient);
assert(postgraphileClient);
this._db = db;
this._ethClient = ethClient;
this._postgraphileClient = postgraphileClient;
this._ethProvider = ethProvider;
this._serverConfig = serverConfig;
this._baseIndexer = new BaseIndexer(this._db, this._ethClient, this._postgraphileClient, this._ethProvider);
const { abi, storageLayout } = artifacts;
@@ -138,7 +138,7 @@ export const main = async (): Promise<any> => {
const jobQueue = new JobQueue({ dbConnectionString, maxCompletionLag: maxCompletionLagInSecs });
await jobQueue.start();
const jobRunner = new JobRunner(jobQueueConfig, config.server, indexer, jobQueue);
const jobRunner = new JobRunner(jobQueueConfig, indexer, jobQueue);
await jobRunner.start();
};
@@ -45,7 +45,7 @@ export const main = async (): Promise<any> => {
// Note: In-memory pubsub works fine for now, as each watcher is a single process anyway.
// Later: https://www.apollographql.com/docs/apollo-server/data/subscriptions/#production-pubsub-libraries
const pubsub = new PubSub();
const indexer = new Indexer(config.server, db, ethClient, ethProvider);
const indexer = new Indexer(config.server, db, ethClient, postgraphileClient, ethProvider);
const jobQueueConfig = config.jobQueue;
assert(jobQueueConfig, 'Missing job queue config');