diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-08-24 13:29:08 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-08-24 13:29:08 +0800 |
commit | 0ad310e096fe8c13553dc40f65363d296a7e84ce (patch) | |
tree | 172099aa99ec43c93e9d86f49c073b80c1999477 /app/scripts/lib | |
parent | 4de977e63e17e7a3804cb2fbc8674212838a8571 (diff) | |
download | tangerine-wallet-browser-0ad310e096fe8c13553dc40f65363d296a7e84ce.tar tangerine-wallet-browser-0ad310e096fe8c13553dc40f65363d296a7e84ce.tar.gz tangerine-wallet-browser-0ad310e096fe8c13553dc40f65363d296a7e84ce.tar.bz2 tangerine-wallet-browser-0ad310e096fe8c13553dc40f65363d296a7e84ce.tar.lz tangerine-wallet-browser-0ad310e096fe8c13553dc40f65363d296a7e84ce.tar.xz tangerine-wallet-browser-0ad310e096fe8c13553dc40f65363d296a7e84ce.tar.zst tangerine-wallet-browser-0ad310e096fe8c13553dc40f65363d296a7e84ce.zip |
Fail transactions after a day of retries
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/pending-tx-tracker.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/scripts/lib/pending-tx-tracker.js b/app/scripts/lib/pending-tx-tracker.js index 19720db3f..b90851b58 100644 --- a/app/scripts/lib/pending-tx-tracker.js +++ b/app/scripts/lib/pending-tx-tracker.js @@ -1,6 +1,7 @@ const EventEmitter = require('events') const EthQuery = require('ethjs-query') const sufficientBalance = require('./util').sufficientBalance +const RETRY_LIMIT = 3500 // Retry 3500 blocks, or about 1 day. /* Utility class for tracking the transactions as they @@ -28,6 +29,7 @@ module.exports = class PendingTransactionTracker extends EventEmitter { this.getBalance = config.getBalance this.getPendingTransactions = config.getPendingTransactions this.publishTransaction = config.publishTransaction + this.giveUpOnTransaction = config.giveUpOnTransaction } // checks if a signed tx is in a block and @@ -100,6 +102,10 @@ module.exports = class PendingTransactionTracker extends EventEmitter { if (balance === undefined) return if (!('retryCount' in txMeta)) txMeta.retryCount = 0 + if (txMeta.retryCount > RETRY_LIMIT) { + return this.giveUpOnTransaction(txMeta.id) + } + // if the value of the transaction is greater then the balance, fail. if (!sufficientBalance(txMeta.txParams, balance)) { const insufficientFundsError = new Error('Insufficient balance during rebroadcast.') @@ -160,4 +166,4 @@ module.exports = class PendingTransactionTracker extends EventEmitter { } nonceGlobalLock.releaseLock() } -}
\ No newline at end of file +} |