mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-12 02:27:31 +00:00
Refactor code to initialize clients (#290)
* Refactor CLI code * Refactor code to initialize clients * Don't return config from function to initialize clients
This commit is contained in:
@@ -12,5 +12,5 @@ export * from './src/events';
|
||||
export * from './src/types';
|
||||
export * from './src/indexer';
|
||||
export * from './src/job-runner';
|
||||
export * from './src/ipld-helper';
|
||||
export * from './src/graph-decimal';
|
||||
export * from './src/ipldHelper';
|
||||
|
||||
@@ -9,9 +9,9 @@ import toml from 'toml';
|
||||
import debug from 'debug';
|
||||
import { ConnectionOptions } from 'typeorm';
|
||||
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
import { Config as CacheConfig, getCache } from '@vulcanize/cache';
|
||||
import { EthClient } from '@vulcanize/ipld-eth-client';
|
||||
import { BaseProvider } from '@ethersproject/providers';
|
||||
|
||||
import { getCustomProvider } from './misc';
|
||||
|
||||
@@ -73,10 +73,7 @@ export const getConfig = async (configFile: string): Promise<Config> => {
|
||||
return config;
|
||||
};
|
||||
|
||||
export const getResetConfig = async (config: Config): Promise<{
|
||||
dbConfig: ConnectionOptions,
|
||||
serverConfig: ServerConfig,
|
||||
upstreamConfig: UpstreamConfig,
|
||||
export const initClients = async (config: Config): Promise<{
|
||||
ethClient: EthClient,
|
||||
postgraphileClient: EthClient,
|
||||
ethProvider: BaseProvider
|
||||
@@ -85,9 +82,10 @@ export const getResetConfig = async (config: Config): Promise<{
|
||||
|
||||
assert(serverConfig, 'Missing server config');
|
||||
assert(dbConfig, 'Missing database config');
|
||||
|
||||
assert(upstreamConfig, 'Missing upstream config');
|
||||
|
||||
const { ethServer: { gqlApiEndpoint, gqlPostgraphileEndpoint, rpcProviderEndpoint }, cache: cacheConfig } = upstreamConfig;
|
||||
|
||||
assert(gqlApiEndpoint, 'Missing upstream ethServer.gqlApiEndpoint');
|
||||
assert(gqlPostgraphileEndpoint, 'Missing upstream ethServer.gqlPostgraphileEndpoint');
|
||||
assert(rpcProviderEndpoint, 'Missing upstream ethServer.rpcProviderEndpoint');
|
||||
@@ -108,9 +106,6 @@ export const getResetConfig = async (config: Config): Promise<{
|
||||
const ethProvider = getCustomProvider(rpcProviderEndpoint);
|
||||
|
||||
return {
|
||||
dbConfig,
|
||||
serverConfig,
|
||||
upstreamConfig,
|
||||
ethClient,
|
||||
postgraphileClient,
|
||||
ethProvider
|
||||
|
||||
@@ -6,7 +6,7 @@ import assert from 'assert';
|
||||
import debug from 'debug';
|
||||
import { In } from 'typeorm';
|
||||
|
||||
import { JobQueueConfig, ServerConfig } from './config';
|
||||
import { JobQueueConfig } from './config';
|
||||
import {
|
||||
JOB_KIND_INDEX,
|
||||
JOB_KIND_PRUNE,
|
||||
@@ -32,13 +32,11 @@ export class JobRunner {
|
||||
_jobQueue: JobQueue
|
||||
_jobQueueConfig: JobQueueConfig
|
||||
_blockProcessStartTime?: Date
|
||||
_serverConfig: ServerConfig
|
||||
|
||||
constructor (jobQueueConfig: JobQueueConfig, serverConfig: ServerConfig, indexer: IndexerInterface, jobQueue: JobQueue) {
|
||||
constructor (jobQueueConfig: JobQueueConfig, indexer: IndexerInterface, jobQueue: JobQueue) {
|
||||
this._indexer = indexer;
|
||||
this._jobQueue = jobQueue;
|
||||
this._jobQueueConfig = jobQueueConfig;
|
||||
this._serverConfig = serverConfig;
|
||||
}
|
||||
|
||||
async processBlock (job: any): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user