Force update of gas price when getting underprice tx error (#554)
This commit is contained in:
parent
ab51370d5a
commit
59e0bf7565
@ -195,7 +195,11 @@ async function main({ msg, ackMsg, nackMsg, channel, scheduleForRetry, scheduleT
|
|||||||
)
|
)
|
||||||
|
|
||||||
const message = e.message.toLowerCase()
|
const message = e.message.toLowerCase()
|
||||||
if (isResend || message.includes('transaction with the same hash was already imported')) {
|
if (message.includes('replacement transaction underpriced')) {
|
||||||
|
logger.info('Replacement transaction underpriced, forcing gas price update')
|
||||||
|
GasPrice.start(config.id)
|
||||||
|
failedTx.push(job)
|
||||||
|
} else if (isResend || message.includes('transaction with the same hash was already imported')) {
|
||||||
resendJobs.push(job)
|
resendJobs.push(job)
|
||||||
} else {
|
} else {
|
||||||
// if initial transaction sending has failed not due to the same hash error
|
// if initial transaction sending has failed not due to the same hash error
|
||||||
|
@ -73,17 +73,20 @@ async function start(chainId, fetchOnce) {
|
|||||||
throw new Error(`Unrecognized chainId '${chainId}'`)
|
throw new Error(`Unrecognized chainId '${chainId}'`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchFn = gasPriceSupplierUrl === 'gas-price-oracle' ? null : () => fetch(gasPriceSupplierUrl)
|
let fetchFn = null
|
||||||
if (fetchOnce) {
|
if (gasPriceSupplierUrl !== 'gas-price-oracle') {
|
||||||
await fetchGasPrice(speedType, factor, bridgeContract, fetchFn)
|
fetchFn = () => fetch(gasPriceSupplierUrl, { timeout: 2000 })
|
||||||
return getPrice()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchGasPriceInterval = setIntervalAndRun(
|
if (fetchOnce) {
|
||||||
|
await fetchGasPrice(speedType, factor, bridgeContract, fetchFn)
|
||||||
|
} else {
|
||||||
|
fetchGasPriceInterval = await setIntervalAndRun(
|
||||||
() => fetchGasPrice(speedType, factor, bridgeContract, fetchFn),
|
() => fetchGasPrice(speedType, factor, bridgeContract, fetchFn),
|
||||||
updateInterval
|
updateInterval
|
||||||
)
|
)
|
||||||
return null
|
}
|
||||||
|
return getPrice()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrice() {
|
function getPrice() {
|
||||||
|
@ -64,9 +64,9 @@ function addExtraGas(gas, extraPercentage, maxGasLimit = Infinity) {
|
|||||||
return BigNumber.min(maxGasLimit, gasWithExtra)
|
return BigNumber.min(maxGasLimit, gasWithExtra)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setIntervalAndRun(f, interval) {
|
async function setIntervalAndRun(f, interval) {
|
||||||
const handler = setInterval(f, interval)
|
const handler = setInterval(f, interval)
|
||||||
f()
|
await f()
|
||||||
return handler
|
return handler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user