From 95c7acb2108e3ee461cf81a9f68242bb64a2cbcf Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Sun, 29 Dec 2013 11:55:54 +0700 Subject: [PATCH] Fix bug in (redundant) check for transaction result immediately before resubmission --- src/js/ripple/transaction.js | 14 ++++++++++++++ src/js/ripple/transactionmanager.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/js/ripple/transaction.js b/src/js/ripple/transaction.js index b88f6436..42507f5e 100644 --- a/src/js/ripple/transaction.js +++ b/src/js/ripple/transaction.js @@ -222,6 +222,20 @@ Transaction.prototype.addSubmittedTxnID = function(hash) { } }; +Transaction.prototype.findResultInCache = function(cache) { + var cached; + + for (var i = this.submittedTxnIDs.length - 1; i >= 0; i--) { + var hash = this.submittedTxnIDs[i]; + cached = cache[hash]; + if (cached != null) { + break; + }; + }; + + return cached; +}; + Transaction.prototype.hash = function(prefix, as_uint256) { if (typeof prefix === 'string') { if (typeof hashprefixes[prefix] === 'undefined') { diff --git a/src/js/ripple/transactionmanager.js b/src/js/ripple/transactionmanager.js index 347993dc..b7ffcee1 100644 --- a/src/js/ripple/transactionmanager.js +++ b/src/js/ripple/transactionmanager.js @@ -215,7 +215,7 @@ TransactionManager.prototype._resubmit = function(ledgers, pending) { return; } - var hashCached = self._cache[pending._hash]; + var hashCached = pending.findResultInCache(self._cache); //[pending._hash]; self._remote._trace('transactionmanager: resubmit: %s', pending.tx_json); if (hashCached) {