Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 'nonce too low' error message on oracle sender #99

Merged
merged 1 commit into from Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions oracle/src/sender.js
Expand Up @@ -13,7 +13,8 @@ const {
privateKeyToAddress,
syncForEach,
waitForFunds,
watchdog
watchdog,
nonceError
} = require('./utils/utils')
const { EXIT_CODES, EXTRA_GAS_PERCENTAGE } = require('./utils/constants')

Expand Down Expand Up @@ -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)
}
}
Expand Down
11 changes: 10 additions & 1 deletion oracle/src/utils/utils.js
Expand Up @@ -96,12 +96,21 @@ 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,
waitForFunds,
addExtraGas,
setIntervalAndRun,
watchdog,
privateKeyToAddress
privateKeyToAddress,
nonceError
}