Prefetch block and txs in historical processing instead of fetching them in events processing (#460)

* Set gzip true in ethersjs provider

* Add timer logs and use StaticJsonRpcProvider

* Fetch block data in historical processing and cache in map

* Fetch txs required for event logs in historical processing

* Process events with prefetched block and txs data in realtime processing

* Clear old TODOs
This commit is contained in:
2023-11-09 18:42:37 +05:30
committed by GitHub
parent c7bcd4c276
commit 695723955f
15 changed files with 398 additions and 219 deletions
+15 -4
View File
@@ -18,7 +18,9 @@ import {
ResultEvent,
StateKind,
EthClient,
UpstreamConfig
UpstreamConfig,
EthFullTransaction,
EthFullBlock
} from '@cerc-io/util';
import { GetStorageAt, getStorageValue, MappingKey, StorageLayout } from '@cerc-io/solidity-mapper';
@@ -117,7 +119,12 @@ export class Indexer implements IndexerInterface {
return [];
}
async fetchAndSaveFilteredEventsAndBlocks (startBlock: number, endBlock: number): Promise<{ blockProgress: BlockProgressInterface, events: DeepPartial<EventInterface>[] }[]> {
async fetchAndSaveFilteredEventsAndBlocks (startBlock: number, endBlock: number): Promise<{
blockProgress: BlockProgressInterface;
events: DeepPartial<EventInterface>[];
ethFullBlock: EthFullBlock;
ethFullTransactions: EthFullTransaction[];
}[]> {
assert(startBlock);
assert(endBlock);
@@ -132,8 +139,12 @@ export class Indexer implements IndexerInterface {
return [];
}
async saveBlockAndFetchEvents (block: BlockProgressInterface): Promise<[BlockProgressInterface, DeepPartial<EventInterface>[]]> {
return [block, []];
async saveBlockAndFetchEvents (block: BlockProgressInterface): Promise<[
BlockProgressInterface,
DeepPartial<EventInterface>[],
EthFullTransaction[]
]> {
return [block, [], []];
}
async removeUnknownEvents (block: BlockProgressInterface): Promise<void> {