Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vasapower committed Sep 23, 2023
1 parent 3ad3719 commit 210dd0d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/lib/web3/getLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ export default async function getLogs(provider, args) {
}

for (var range of ranges) {
var start = range[0]
logs.push(
sendAsync(provider, 'eth_getLogs', {
...args,
fromBlock: toHex(range[0]),
toBlock: toHex(range[1]),
}).catch((e) => {
console.log(e)
return []
})
)
/*var start = range[0]
var end = start + interval
end = end > range[1] ? range[1] : end
Expand Down Expand Up @@ -130,7 +140,7 @@ export default async function getLogs(provider, args) {
start = end
end = start + interval
end = end > range[1] ? range[1] : end
}
}*/
}

logs = await Promise.all(logs)
Expand Down
12 changes: 8 additions & 4 deletions src/lib/web3/sendAsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function instrumentProvider(provider, method) {
async function sendAsyncInternal(provider, method, params) {
return await new Promise(async function (ok, ko) {
try {
await (provider.sendAsync || provider.send).call(
await (provider.sendAsync || provider.send || provider.request).call(
provider,
{
jsonrpc: '2.0',
Expand All @@ -74,8 +74,7 @@ async function sendAsyncInternal(provider, method, params) {
})
}

async function sendAsync(provider, method) {
var params = [...arguments].slice(2) || []
async function _sendAsync(provider, method, params) {
while (true) {
try {
return await sendAsyncInternal(provider, method, params)
Expand All @@ -93,11 +92,16 @@ async function sendAsync(provider, method) {
if (provider === instrumentedProvider) {
throw e
}
return await sendAsyncInternal(instrumentedProvider, method, params)
return await _sendAsync(instrumentedProvider, method, params)
}
await new Promise((ok) => setTimeout(ok, 700))
}
}
}

function sendAsync(provider, method) {
var params = [...arguments].slice(2) || []
return _sendAsync(provider, method, params)
}

export default sendAsync

0 comments on commit 210dd0d

Please sign in to comment.