Merge pull request #99 from poanetwork/oracle-nonce-too-low

Handle 'nonce too low' error message on oracle sender
This commit is contained in:
Alexander Kolotov 2019-06-07 23:28:25 +03:00 committed by GitHub
commit 2b3b2d41ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

@ -13,7 +13,8 @@ const {
privateKeyToAddress,
syncForEach,
waitForFunds,
watchdog
watchdog,
nonceError
} = require('./utils/utils')
const { EXIT_CODES, EXTRA_GAS_PERCENTAGE } = require('./utils/constants')
@ -152,10 +153,7 @@ async function main({ msg, ackMsg, nackMsg, sendToQueue, channel }) {
logger.error(
`Insufficient funds: ${currentBalance}. Stop processing messages until the balance is at least ${minimumBalance}.`
)
} else if (
e.message.includes('Transaction nonce is too low') ||
e.message.includes('transaction with same nonce in the queue')
) {
} else if (nonceError(e)) {
nonce = await readNonce(true)
}
}

@ -96,6 +96,14 @@ function privateKeyToAddress(privateKey) {
: null
}
function nonceError(e) {
return (
e.message.includes('Transaction nonce is too low') ||
e.message.includes('nonce too low') ||
e.message.includes('transaction with same nonce in the queue')
)
}
module.exports = {
syncForEach,
checkHTTPS,
@ -103,5 +111,6 @@ module.exports = {
addExtraGas,
setIntervalAndRun,
watchdog,
privateKeyToAddress
privateKeyToAddress,
nonceError
}