Fix resend of stuck pending transactions (#514)

This commit is contained in:
Kirill Fedoseev 2021-02-25 01:11:28 +03:00 committed by GitHub
parent 894134ba26
commit 626f9376b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)