From 626f9376b230785701a64ff5e991bce5f5e3d541 Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Thu, 25 Feb 2021 01:11:28 +0300 Subject: [PATCH] Fix resend of stuck pending transactions (#514) --- oracle/src/sender.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/oracle/src/sender.js b/oracle/src/sender.js index 172631a5..659d0b5f 100644 --- a/oracle/src/sender.js +++ b/oracle/src/sender.js @@ -173,15 +173,18 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry, scheduleT `Tx Failed for event Tx ${job.transactionReference}.`, e.message ) - if (!e.message.toLowerCase().includes('transaction with the same hash was already imported')) { - if (isResend) { - resendJobs.push(job) - } else { - failedTx.push(job) - } + + const message = e.message.toLowerCase() + if (isResend || message.includes('transaction with the same hash was already imported')) { + resendJobs.push(job) + } else { + // if initial transaction sending has failed not due to the same hash error + // send it to the failed tx queue + // this will result in the sooner resend attempt than if using resendJobs + failedTx.push(job) } - if (e.message.toLowerCase().includes('insufficient funds')) { + if (message.includes('insufficient funds')) { insufficientFunds = true const currentBalance = await web3Instance.eth.getBalance(ORACLE_VALIDATOR_ADDRESS) minimumBalance = gasLimit.multipliedBy(gasPrice)