Avoid eth_getLogs query if no subgraph event handlers exist

This commit is contained in:
Nabarun 2024-06-19 18:33:06 +05:30
parent 45177bb2ce
commit f7d2d0941b
5 changed files with 60 additions and 5 deletions

View File

@ -651,7 +651,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events and txs only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {

View File

@ -657,7 +657,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events and txs only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {

View File

@ -1165,7 +1165,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events and txs only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {

View File

@ -1040,7 +1040,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events and txs only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {

View File

@ -1424,7 +1424,18 @@ export class Indexer implements IndexerInterface {
assert(blockHash);
assert(blockNumber);
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
let dbEvents: DeepPartial<Event>[] = [];
let transactions: EthFullTransaction[] = [];
// Fetch events only if subgraph config has any event handlers
if (this._graphWatcher.eventHandlerExists) {
({ events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
blockHash,
blockNumber,
this.eventSignaturesMap,
this.parseEventNameAndArgs.bind(this)
));
}
const dbTx = await this._db.createTransactionRunner();
try {