improve rpc rate-limit conditions

This commit is contained in:
gozzy 2023-03-22 20:50:13 +00:00
parent aef16eda5f
commit 2b61afbafe
2 changed files with 5 additions and 6 deletions

@ -280,8 +280,8 @@ class EventService {
} catch (e) {
if (shouldRetry) {
i = i + 1
// maximum 10 second buffer for rate-limiting
await sleep(2000 * i)
// maximum 5 second buffer for rate-limiting
await sleep(1000 * i)
events = await this.getEventsPartFromRpc(
{
@ -317,6 +317,7 @@ class EventService {
(e, i) =>
new Promise(async (resolve) => {
try {
sleep(20 * i)
const { events } = await this.getEventsPartFromRpc({ ...e }, true)
resolve(events)
} catch (e) {
@ -369,7 +370,6 @@ class EventService {
}
}
await this.updateEventProgress(progressIndex / batchCount, type)
await sleep(200)
}
events = flattenNArray(events)

@ -37,7 +37,7 @@ class RelayerRegister {
resolve(registeredEventsPart)
} catch (error) {
if (shouldRetry) {
sleep(1000)
sleep(500)
const events = this.fetchEvents({ fromBlock, toBlock })
@ -61,8 +61,7 @@ class RelayerRegister {
const promises = new Array(chunkCount).fill('').map(
(_, i) =>
new Promise((resolve) => {
sleep(300)
sleep(20 * i)
const batch = this.fetchEvents(
{
fromBlock: i * blockDenom + fromBlock,