mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
pending-tx - check time stamp instead of block number for resubmit
This commit is contained in:
parent
852c27bad4
commit
ec9c528313
@ -59,7 +59,7 @@ module.exports = class TransactionController extends EventEmitter {
|
||||
this.pendingTxTracker = new PendingTransactionTracker({
|
||||
provider: this.provider,
|
||||
nonceTracker: this.nonceTracker,
|
||||
retryLimit: 3500, // Retry 3500 blocks, or about 1 day.
|
||||
retryTimePeriod: 86400000, // Retry 3500 blocks, or about 1 day.
|
||||
publishTransaction: (rawTx) => this.query.sendRawTransaction(rawTx),
|
||||
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager),
|
||||
})
|
||||
|
@ -22,7 +22,8 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
||||
super()
|
||||
this.query = new EthQuery(config.provider)
|
||||
this.nonceTracker = config.nonceTracker
|
||||
this.retryLimit = config.retryLimit || Infinity
|
||||
// default is one day
|
||||
this.retryTimePeriod = config.retryTimePeriod || 86400000
|
||||
this.getPendingTransactions = config.getPendingTransactions
|
||||
this.publishTransaction = config.publishTransaction
|
||||
}
|
||||
@ -99,8 +100,8 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
||||
}
|
||||
|
||||
async _resubmitTx (txMeta) {
|
||||
if (txMeta.retryCount > this.retryLimit) {
|
||||
const err = new Error(`Gave up submitting after ${this.retryLimit} blocks un-mined.`)
|
||||
if (Date.now() > txMeta.time + this.retryTimePeriod) {
|
||||
const err = new Error(`Gave up submitting after ${this.retryTimePeriod / 3.6e+6} hours.`)
|
||||
return this.emit('tx:failed', txMeta.id, err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user