diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-06-14 01:45:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-14 01:45:21 +0800 |
commit | dd7e11d196cdc6b05439f9d49862ea20af9eefce (patch) | |
tree | ff9ae99983c3498d994762a2de8ff8027d181e63 /app/scripts | |
parent | eccb8b8f80b9d8bda70106bd3a089d059ea9d44f (diff) | |
parent | ec3383c16275f8d4594323b7b4ec38b447844e68 (diff) | |
download | tangerine-wallet-browser-dd7e11d196cdc6b05439f9d49862ea20af9eefce.tar tangerine-wallet-browser-dd7e11d196cdc6b05439f9d49862ea20af9eefce.tar.gz tangerine-wallet-browser-dd7e11d196cdc6b05439f9d49862ea20af9eefce.tar.bz2 tangerine-wallet-browser-dd7e11d196cdc6b05439f9d49862ea20af9eefce.tar.lz tangerine-wallet-browser-dd7e11d196cdc6b05439f9d49862ea20af9eefce.tar.xz tangerine-wallet-browser-dd7e11d196cdc6b05439f9d49862ea20af9eefce.tar.zst tangerine-wallet-browser-dd7e11d196cdc6b05439f9d49862ea20af9eefce.zip |
Merge pull request #1598 from MetaMask/txRetry
put tx resubmission on the block event
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/controllers/transactions.js | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index d4603aafa..2db8041eb 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -9,7 +9,6 @@ const createId = require('../lib/random-id') const denodeify = require('denodeify') const RETRY_LIMIT = 200 -const RESUBMIT_INTERVAL = 10000 // Ten seconds module.exports = class TransactionController extends EventEmitter { constructor (opts) { @@ -26,6 +25,7 @@ module.exports = class TransactionController extends EventEmitter { this.query = opts.ethQuery this.txProviderUtils = new TxProviderUtil(this.query) this.blockTracker.on('block', this.checkForTxInBlock.bind(this)) + this.blockTracker.on('block', this.resubmitPendingTxs.bind(this)) this.signEthTx = opts.signTransaction this.nonceLock = Semaphore(1) @@ -34,8 +34,6 @@ module.exports = class TransactionController extends EventEmitter { this.store.subscribe(() => this._updateMemstore()) this.networkStore.subscribe(() => this._updateMemstore()) this.preferencesStore.subscribe(() => this._updateMemstore()) - - this.continuallyResubmitPendingTxs() } getState () { @@ -409,18 +407,15 @@ module.exports = class TransactionController extends EventEmitter { this.memStore.updateState({ unapprovedTxs, selectedAddressTxList }) } - continuallyResubmitPendingTxs () { + resubmitPendingTxs () { const pending = this.getTxsByMetaData('status', 'submitted') + // only try resubmitting if their are transactions to resubmit + if (!pending.length) return const resubmit = denodeify(this.resubmitTx.bind(this)) Promise.all(pending.map(txMeta => resubmit(txMeta))) .catch((reason) => { log.info('Problem resubmitting tx', reason) }) - .then(() => { - global.setTimeout(() => { - this.continuallyResubmitPendingTxs() - }, RESUBMIT_INTERVAL) - }) } resubmitTx (txMeta, cb) { |