Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve block processing time and GQL queries in uniswap-info-watcher #366

Merged
merged 12 commits into from
Oct 4, 2022
Merged
4 changes: 4 additions & 0 deletions packages/erc20-watcher/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ export class Indexer {
await this.triggerIndexingOnEvent(event);
}

async processBlock (blockProgress: BlockProgress): Promise<void> {
// Method for processing on indexing new block.
}

parseEventNameAndArgs (kind: string, logObj: any): any {
let eventName = UNKNOWN_EVENT_NAME;
let eventInfo = {};
Expand Down
18 changes: 16 additions & 2 deletions packages/ipld-eth-client/src/eth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export class EthClient {
async getStorageAt ({ blockHash, contract, slot }: { blockHash: string, contract: string, slot: string }): Promise<{ value: string, proof: { data: string } }> {
slot = `0x${padKey(slot)}`;

console.time(`time:eth-client#getStorageAt-${JSON.stringify({ blockHash, contract, slot })}`);
const result = await this._getCachedOrFetch('getStorageAt', { blockHash, contract, slot });
console.timeEnd(`time:eth-client#getStorageAt-${JSON.stringify({ blockHash, contract, slot })}`);
const { getStorageAt: { value, cid, ipldBlock } } = result;

return {
Expand All @@ -63,27 +65,37 @@ export class EthClient {
}

async getBlockWithTransactions ({ blockNumber, blockHash }: { blockNumber?: number, blockHash?: string }): Promise<any> {
return this._graphqlClient.query(
console.time(`time:eth-client#getBlockWithTransactions-${JSON.stringify({ blockNumber, blockHash })}`);
const result = await this._graphqlClient.query(
ethQueries.getBlockWithTransactions,
{
blockNumber: blockNumber?.toString(),
blockHash
}
);
console.timeEnd(`time:eth-client#getBlockWithTransactions-${JSON.stringify({ blockNumber, blockHash })}`);

return result;
}

async getBlocks ({ blockNumber, blockHash }: { blockNumber?: number, blockHash?: string }): Promise<any> {
return this._graphqlClient.query(
console.time(`time:eth-client#getBlocks-${JSON.stringify({ blockNumber, blockHash })}`);
const result = await this._graphqlClient.query(
ethQueries.getBlocks,
{
blockNumber: blockNumber?.toString(),
blockHash
}
);
console.timeEnd(`time:eth-client#getBlocks-${JSON.stringify({ blockNumber, blockHash })}`);

return result;
}

async getBlockByHash (blockHash?: string): Promise<any> {
console.time(`time:eth-client#getBlockByHash-${blockHash}`);
const result = await this._graphqlClient.query(ethQueries.getBlockByHash, { blockHash });
console.timeEnd(`time:eth-client#getBlockByHash-${blockHash}`);

return {
block: {
Expand All @@ -95,7 +107,9 @@ export class EthClient {
}

async getLogs (vars: Vars): Promise<any> {
console.time(`time:eth-client#getLogs-${JSON.stringify(vars)}`);
const result = await this._getCachedOrFetch('getLogs', vars);
console.timeEnd(`time:eth-client#getLogs-${JSON.stringify(vars)}`);
const {
getLogs: resultLogs,
block: {
Expand Down
Loading