diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-06-13 07:11:37 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-06-13 07:11:37 +0800 |
commit | 96fa29ffbce841977ae02acaba2d8114436262d4 (patch) | |
tree | c4c6b63df984af7c343359c6c3614f3312d0cf7b | |
parent | 33a32bb06be408d197d2f7784d9c1a9e04280fda (diff) | |
download | tangerine-wallet-browser-96fa29ffbce841977ae02acaba2d8114436262d4.tar tangerine-wallet-browser-96fa29ffbce841977ae02acaba2d8114436262d4.tar.gz tangerine-wallet-browser-96fa29ffbce841977ae02acaba2d8114436262d4.tar.bz2 tangerine-wallet-browser-96fa29ffbce841977ae02acaba2d8114436262d4.tar.lz tangerine-wallet-browser-96fa29ffbce841977ae02acaba2d8114436262d4.tar.xz tangerine-wallet-browser-96fa29ffbce841977ae02acaba2d8114436262d4.tar.zst tangerine-wallet-browser-96fa29ffbce841977ae02acaba2d8114436262d4.zip |
put tx resubmission on the block event
-rw-r--r-- | app/scripts/controllers/transactions.js | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index faccf1ab1..bf24523cc 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.continuallyResubmitPendingTxs.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 () { @@ -411,16 +409,13 @@ module.exports = class TransactionController extends EventEmitter { continuallyResubmitPendingTxs () { 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) { |