Commit 78f294c3 authored by Moody Salem's avatar Moody Salem

more retries since metamask nodes often return old data

parent 90d24a26
......@@ -143,7 +143,8 @@ export default function Updater() {
)
chunkedCalls.forEach((chunk, index) =>
retry(() => fetchChunk(multicallContract, chunk, latestBlockNumber))
// todo: cancel retries when the block number updates
retry(() => fetchChunk(multicallContract, chunk, latestBlockNumber), { n: 10, minWait: 1000, maxWait: 1500 })
.then(({ results: returnData, blockNumber: fetchBlockNumber }) => {
// accumulates the length of all previous indices
const firstCallKeyIndex = chunkedCalls.slice(0, index).reduce<number>((memo, curr) => memo + curr.length, 0)
......
......@@ -13,6 +13,7 @@ function waitRandom(min: number, max: number): Promise<void> {
* @param minWait min wait between retries in ms
* @param maxWait max wait between retries in ms
*/
// todo: support cancelling the retry
export function retry<T>(
fn: () => Promise<T>,
{ n = 3, minWait = 500, maxWait = 1000 }: { n?: number; minWait?: number; maxWait?: number } = {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment