mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-07-29 19:32:06 +00:00
Codegen changes for avoiding eth_getLogs when no subgraph event handlers exist
This commit is contained in:
parent
4d2816e61f
commit
f63d35b336
@ -10,8 +10,7 @@
|
|||||||
checkpointInterval = 2000
|
checkpointInterval = 2000
|
||||||
|
|
||||||
# Enable state creation
|
# Enable state creation
|
||||||
# CAUTION: Disable only if state creation is not desired or can be filled subsequently
|
enableState = false
|
||||||
enableState = true
|
|
||||||
|
|
||||||
{{#if (subgraphPath)}}
|
{{#if (subgraphPath)}}
|
||||||
subgraphPath = "./subgraph-build"
|
subgraphPath = "./subgraph-build"
|
||||||
|
@ -829,6 +829,7 @@ export class Indexer implements IndexerInterface {
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
_populateRelationsMap (): void {
|
_populateRelationsMap (): void {
|
||||||
{{#each subgraphEntities as | subgraphEntity |}}
|
{{#each subgraphEntities as | subgraphEntity |}}
|
||||||
{{#if subgraphEntity.relations}}
|
{{#if subgraphEntity.relations}}
|
||||||
@ -867,7 +868,27 @@ export class Indexer implements IndexerInterface {
|
|||||||
assert(blockHash);
|
assert(blockHash);
|
||||||
assert(blockNumber);
|
assert(blockNumber);
|
||||||
|
|
||||||
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(blockHash, blockNumber, this.eventSignaturesMap, this.parseEventNameAndArgs.bind(this));
|
{{#if (subgraphPath)}}
|
||||||
|
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)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
{{else~}}
|
||||||
|
const { events: dbEvents, transactions } = await this._baseIndexer.fetchEvents(
|
||||||
|
blockHash,
|
||||||
|
blockNumber,
|
||||||
|
this.eventSignaturesMap,
|
||||||
|
this.parseEventNameAndArgs.bind(this)
|
||||||
|
);
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
const dbTx = await this._db.createTransactionRunner();
|
const dbTx = await this._db.createTransactionRunner();
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user