mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-09 09:14:06 +00:00
Wait for events processing to complete before continuing historical blocks processing (#450)
* Wait for events queue to be empty before continuing historical processing * Make historicalLogsBlockRange and historicalMaxFetchAhead configurable * Perform single RPC request for multiple addresses
This commit is contained in:
@@ -135,6 +135,12 @@ export class BaseCmd {
|
||||
// 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();
|
||||
this._eventWatcher = new EventWatcher(this._config.server, this._clients.ethClient, this._indexer, pubsub, this._jobQueue);
|
||||
|
||||
const config = {
|
||||
server: this._config.server,
|
||||
jobQueue: this._config.jobQueue
|
||||
};
|
||||
|
||||
this._eventWatcher = new EventWatcher(config, this._clients.ethClient, this._indexer, pubsub, this._jobQueue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ export class JobRunnerCmd {
|
||||
|
||||
const jobRunner = new JobRunner(config.jobQueue, indexer, jobQueue);
|
||||
|
||||
await jobRunner.jobQueue.deleteAllJobs();
|
||||
await jobRunner.jobQueue.deleteAllJobs('completed');
|
||||
await jobRunner.resetToPrevIndexedBlock();
|
||||
|
||||
await startJobRunner(jobRunner);
|
||||
|
||||
@@ -281,8 +281,8 @@ export class ServerCmd {
|
||||
assert(eventWatcher);
|
||||
|
||||
if (config.server.kind === KIND_ACTIVE) {
|
||||
// Delete jobs to prevent creating jobs after completion of processing previous block.
|
||||
await jobQueue.deleteAllJobs();
|
||||
// Delete jobs before completed state to prevent creating jobs after completion of processing previous block.
|
||||
await jobQueue.deleteAllJobs('completed');
|
||||
await eventWatcher.start();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user