forked from tornadocash/classic-ui
fix: incorrect calculation of rpc requests chunks count
This commit is contained in:
parent
9896506583
commit
dea8043806
@ -54,7 +54,12 @@ async function getEventsFromBlockPart({ echoContract, address, currentBlockNumbe
|
|||||||
address
|
address
|
||||||
})
|
})
|
||||||
if (partOfEvents) {
|
if (partOfEvents) {
|
||||||
events = events.concat(partOfEvents)
|
events = events.concat(
|
||||||
|
partOfEvents.map((event) => ({
|
||||||
|
address: event.returnValues.who,
|
||||||
|
encryptedAccount: event.returnValues.data
|
||||||
|
}))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
fromBlock = toBlock
|
fromBlock = toBlock
|
||||||
toBlock += part
|
toBlock += part
|
||||||
|
@ -488,23 +488,27 @@ const actions = {
|
|||||||
deployedBlock = lastSyncBlock
|
deployedBlock = lastSyncBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
let NUMBER_PARTS = hasCache ? 2 : 10
|
const blockDifference = Math.ceil(currentBlockNumber - deployedBlock)
|
||||||
|
const divisor = hasCache ? 2 : 10
|
||||||
|
|
||||||
|
let blockRange = blockDifference > divisor ? blockDifference / divisor : blockDifference
|
||||||
|
|
||||||
if (Number(netId) === 56) {
|
if (Number(netId) === 56) {
|
||||||
NUMBER_PARTS = parseInt((currentBlockNumber - deployedBlock) / 4950) || 1
|
blockRange = 4950
|
||||||
}
|
}
|
||||||
|
|
||||||
const part = parseInt((currentBlockNumber - deployedBlock) / NUMBER_PARTS)
|
let numberParts = blockDifference === 0 ? 1 : Math.ceil(blockDifference / blockRange)
|
||||||
|
const part = Math.ceil(blockDifference / numberParts)
|
||||||
|
|
||||||
let fromBlock = deployedBlock
|
let fromBlock = deployedBlock
|
||||||
let toBlock = deployedBlock + part
|
let toBlock = deployedBlock + part
|
||||||
|
|
||||||
if (toBlock >= currentBlockNumber || toBlock === deployedBlock) {
|
if (toBlock >= currentBlockNumber || toBlock === deployedBlock) {
|
||||||
toBlock = 'latest'
|
toBlock = 'latest'
|
||||||
NUMBER_PARTS = 1
|
numberParts = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < NUMBER_PARTS; i++) {
|
for (let i = 0; i < numberParts; i++) {
|
||||||
const partOfEvents = await contractInstance.getPastEvents('EncryptedNote', {
|
const partOfEvents = await contractInstance.getPastEvents('EncryptedNote', {
|
||||||
toBlock,
|
toBlock,
|
||||||
fromBlock
|
fromBlock
|
||||||
|
Loading…
Reference in New Issue
Block a user