Clear caches when queue empties

This commit is contained in:
wltsmrz
2014-02-19 12:21:55 -08:00
parent 5a15c5b1d5
commit 5ca5c73c34

View File

@@ -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();
};