From 5ca5c73c34ef05d522be020ac7b87b4b2c2abd4d Mon Sep 17 00:00:00 2001 From: wltsmrz Date: Wed, 19 Feb 2014 12:21:55 -0800 Subject: [PATCH] Clear caches when queue empties --- src/js/ripple/transactionqueue.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/js/ripple/transactionqueue.js b/src/js/ripple/transactionqueue.js index aaddb013..d013a441 100644 --- a/src/js/ripple/transactionqueue.js +++ b/src/js/ripple/transactionqueue.js @@ -6,12 +6,19 @@ var Transaction = require('./transaction').Transaction; function TransactionQueue() { + var self = this; + this._queue = [ ]; this._idCache = { }; this._sequenceCache = { }; this._save = void(0); }; +TransactionQueue.prototype.clearCache = function() { + this._idCache = { }; + this._sequenceCache = { }; +}; + TransactionQueue.prototype.save = function() { if (typeof this._save !== 'function') return; @@ -89,6 +96,10 @@ TransactionQueue.prototype.remove = function(tx) { } } + if (!this._queue.length) { + this.clearCache(); + } + this.save(); };