mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
Avoid updating StateSyncStatus table when enableState flag is set to false (#440)
* Handle zero hash canonical block incase of FEVM null block * Fix json-bigint parse in processBatchEvents * Avoid updating SyncStatus table when enableState is false
This commit is contained in:
@@ -8,7 +8,7 @@ import debug from 'debug';
|
||||
{{#if queries}}
|
||||
import JSONbig from 'json-bigint';
|
||||
{{/if}}
|
||||
import { ethers } from 'ethers';
|
||||
import { ethers, constants } from 'ethers';
|
||||
{{#if (subgraphPath)}}
|
||||
import { SelectionNode } from 'graphql';
|
||||
{{/if}}
|
||||
@@ -493,7 +493,11 @@ export class Indexer implements IndexerInterface {
|
||||
return this._db.getStateSyncStatus();
|
||||
}
|
||||
|
||||
async updateStateSyncStatusIndexedBlock (blockNumber: number, force?: boolean): Promise<StateSyncStatus> {
|
||||
async updateStateSyncStatusIndexedBlock (blockNumber: number, force?: boolean): Promise<StateSyncStatus | undefined> {
|
||||
if (!this._serverConfig.enableState) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dbTx = await this._db.createTransactionRunner();
|
||||
let res;
|
||||
|
||||
@@ -527,10 +531,14 @@ export class Indexer implements IndexerInterface {
|
||||
return res;
|
||||
}
|
||||
|
||||
async getLatestCanonicalBlock (): Promise<BlockProgress> {
|
||||
async getLatestCanonicalBlock (): Promise<BlockProgress | undefined> {
|
||||
const syncStatus = await this.getSyncStatus();
|
||||
assert(syncStatus);
|
||||
|
||||
if (syncStatus.latestCanonicalBlockHash === constants.HashZero) {
|
||||
return;
|
||||
}
|
||||
|
||||
const latestCanonicalBlock = await this.getBlockProgress(syncStatus.latestCanonicalBlockHash);
|
||||
assert(latestCanonicalBlock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user