aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-08-24 13:41:51 +0800
committerGitHub <noreply@github.com>2017-08-24 13:41:51 +0800
commit799c4cb6903bd7395c82abe879978cc911ae0a36 (patch)
treeb83bc650ce00e109a79ccc71c289bca40a3687e7 /app
parent4de977e63e17e7a3804cb2fbc8674212838a8571 (diff)
parent941e5ff1252f792e1572c3fd77d7fff086a647c6 (diff)
downloadtangerine-wallet-browser-799c4cb6903bd7395c82abe879978cc911ae0a36.tar
tangerine-wallet-browser-799c4cb6903bd7395c82abe879978cc911ae0a36.tar.gz
tangerine-wallet-browser-799c4cb6903bd7395c82abe879978cc911ae0a36.tar.bz2
tangerine-wallet-browser-799c4cb6903bd7395c82abe879978cc911ae0a36.tar.lz
tangerine-wallet-browser-799c4cb6903bd7395c82abe879978cc911ae0a36.tar.xz
tangerine-wallet-browser-799c4cb6903bd7395c82abe879978cc911ae0a36.tar.zst
tangerine-wallet-browser-799c4cb6903bd7395c82abe879978cc911ae0a36.zip
Merge pull request #1971 from MetaMask/SetMaxRetryLimit
Set max retry limit
Diffstat (limited to 'app')
-rw-r--r--app/scripts/controllers/transactions.js6
-rw-r--r--app/scripts/lib/pending-tx-tracker.js8
2 files changed, 12 insertions, 2 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 6f49c9633..fb3be6073 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -40,6 +40,10 @@ module.exports = class TransactionController extends EventEmitter {
err: undefined,
})
},
+ giveUpOnTransaction: (txId) => {
+ const msg = `Gave up submitting after 3500 blocks un-mined.`
+ this.setTxStatusFailed(txId, msg)
+ },
})
this.query = new EthQuery(this.provider)
this.txProviderUtil = new TxProviderUtil(this.provider)
@@ -451,4 +455,4 @@ module.exports = class TransactionController extends EventEmitter {
})
this.memStore.updateState({ unapprovedTxs, selectedAddressTxList })
}
-} \ No newline at end of file
+}
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
+}