mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 10:45:10 +02:00
Try to catch arbitrum error
This commit is contained in:
parent
95ad97c870
commit
57f4f76f8b
@ -1093,6 +1093,8 @@ SMART CONTRACT EVENTS - SYNC BLOCKS
|
||||
|
||||
*/
|
||||
|
||||
hasError = false;
|
||||
|
||||
// Syncs events database
|
||||
const syncEvents = function (toBlock) {
|
||||
console.log("Starting sync process for Bonding Manager events to block " + toBlock);
|
||||
@ -1148,6 +1150,9 @@ const syncEvents = function (toBlock) {
|
||||
}
|
||||
catch (err) {
|
||||
console.log("FATAL ERROR: ", err);
|
||||
hasError = true;
|
||||
isEventSyncing = false;
|
||||
return;
|
||||
}
|
||||
isEventSyncing = false;
|
||||
});
|
||||
@ -1196,6 +1201,9 @@ const syncTickets = function (toBlock) {
|
||||
}
|
||||
catch (err) {
|
||||
console.log("FATAL ERROR: ", err);
|
||||
hasError = true;
|
||||
isTicketSyncing = false;
|
||||
return;
|
||||
}
|
||||
isTicketSyncing = false;
|
||||
});
|
||||
@ -1415,6 +1423,7 @@ const initSync = async function () {
|
||||
let cycle = 0;
|
||||
// Does the actual looping over last parsed block -> latest block in chain
|
||||
const handleSync = async function () {
|
||||
try {
|
||||
if (!CONF_DISABLE_DB && !startedInitSync) {
|
||||
console.log("Preloading all the things from the database");
|
||||
await initSync();
|
||||
@ -1432,7 +1441,8 @@ const handleSync = async function () {
|
||||
console.log("No new blocks. Sleeping for 10 seconds...");
|
||||
setTimeout(() => {
|
||||
handleSync();
|
||||
}, 10000)
|
||||
}, 10000);
|
||||
return;
|
||||
}
|
||||
console.log("Needs to sync " + (latestBlockInChain - lastBlockEvents) + " blocks for Events sync");
|
||||
console.log("Needs to sync " + (latestBlockInChain - lastBlockTickets) + " blocks for Tickets sync");
|
||||
@ -1457,6 +1467,9 @@ const handleSync = async function () {
|
||||
// Then loop until we have reached the last known block
|
||||
while (isEventSyncing || isTicketSyncing || !getFinalTickets || !getFinalEvents) {
|
||||
await sleep(500);
|
||||
if (hasError){
|
||||
throw("Error while syncing");
|
||||
}
|
||||
if (isEventSyncing) {
|
||||
console.log("Parsed " + lastBlockEvents + " out of " + latestBlockInChain + " blocks for Event sync");
|
||||
} else if (!getFinalEvents) {
|
||||
@ -1485,7 +1498,19 @@ const handleSync = async function () {
|
||||
isSyncing = false;
|
||||
setTimeout(() => {
|
||||
handleSync();
|
||||
}, 10000)
|
||||
}, 10000);
|
||||
return;
|
||||
}
|
||||
catch (err) {
|
||||
console.log("Error while syncing. Retrying in 30 seconds");
|
||||
console.log("latestBlockInChain " + latestBlockInChain);
|
||||
console.log("lastBlockEvents " + lastBlockEvents);
|
||||
console.log("lastBlockTickets " + lastBlockTickets);
|
||||
isSyncing = false;
|
||||
setTimeout(() => {
|
||||
handleSync();
|
||||
}, 30000)
|
||||
}
|
||||
};
|
||||
if (!isSyncing && !CONF_SIMPLE_MODE) {
|
||||
console.log("Starting sync process");
|
||||
|
Loading…
x
Reference in New Issue
Block a user