Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Handle rate limit #25

Merged
merged 9 commits into from
Nov 10, 2022
Merged

Handle rate limit #25

merged 9 commits into from
Nov 10, 2022

Conversation

bz888
Copy link
Contributor

@bz888 bz888 commented Nov 7, 2022

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes subquery/subql#1293

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have tested locally
  • I have performed a self review of my changes
  • Linked to any relevant issues
  • My code is up to date with the base branch

@bz888 bz888 requested a review from stwiname November 7, 2022 01:30
packages/node/src/avalanche/api.avalanche.ts Outdated Show resolved Hide resolved
return this.callMethod(method, params, retries);
} else {
const error = new Error(e.message);
logger.error(error, `Retry: ${retries} failed`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.error(error, `Retry: ${retries} failed`);
logger.error(error, `Rate limit retries failed after ${RETRY_COUNT}`);

async callMethod(
method: string,
params: object[] | object,
retries: number,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets provide a default then we don't need as many args elsewhere

Suggested change
retries: number,
retries = RETRY_COUNT,

@@ -170,35 +175,89 @@ export class AvalancheApi implements ApiWrapper<AvalancheBlockWrapper> {
return BigNumber.from(res.data.result).toNumber();
}

async callMethod(
method: string,
params: object[] | object,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
params: object[] | object,
params: any[],

}),
);
return new AvalancheBlockWrapped(block);
return this.fetchBlock(num);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await

@bz888 bz888 merged commit 02e7017 into main Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better Rate Limit Handling with Avalanche
3 participants