mirror of
https://github.com/tornadocash/tornado-cli.git
synced 2024-11-21 17:27:07 +01:00
Fixed web3 overflow bug for non-geth rpc nodes
This commit is contained in:
parent
62451ec5ce
commit
04623a23e6
12
cli.js
12
cli.js
@ -700,7 +700,7 @@ function initJson(file) {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fs.readFile(file, 'utf8', (error, data) => {
|
fs.readFile(file, 'utf8', (error, data) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(error);
|
resolve([]);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resolve(JSON.parse(data));
|
resolve(JSON.parse(data));
|
||||||
@ -750,10 +750,16 @@ async function fetchEvents({ type, currency, amount}) {
|
|||||||
for (let i=startBlock; i < targetBlock; i+=chunks) {
|
for (let i=startBlock; i < targetBlock; i+=chunks) {
|
||||||
let fetchedEvents = [];
|
let fetchedEvents = [];
|
||||||
async function fetchLatestEvents(i) {
|
async function fetchLatestEvents(i) {
|
||||||
|
let j;
|
||||||
|
if (i+chunks-1 > targetBlock) {
|
||||||
|
j = targetBlock;
|
||||||
|
} else {
|
||||||
|
j = i+chunks-1;
|
||||||
|
}
|
||||||
await tornadoContract.getPastEvents(capitalizeFirstLetter(type), {
|
await tornadoContract.getPastEvents(capitalizeFirstLetter(type), {
|
||||||
fromBlock: i,
|
fromBlock: i,
|
||||||
toBlock: i+chunks-1,
|
toBlock: j,
|
||||||
}).then(r => { fetchedEvents = fetchedEvents.concat(r); console.log("Fetched",amount,currency.toUpperCase(),type,"events to block:", i+chunks-1) }, err => { console.error(i + " failed fetching",type,"events from node", err); process.exit(1); }).catch(console.log);
|
}).then(r => { fetchedEvents = fetchedEvents.concat(r); console.log("Fetched",amount,currency.toUpperCase(),type,"events to block:", j) }, err => { console.error(i + " failed fetching",type,"events from node", err); process.exit(1); }).catch(console.log);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mapDepositEvents() {
|
async function mapDepositEvents() {
|
||||||
|
Loading…
Reference in New Issue
Block a user