From 5a6099e992be1da2baa999187c001891511e239f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 24 Sep 2016 02:34:00 -0700 Subject: [PATCH] mempool: fix mempool.has(). --- lib/mempool/mempool.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/mempool/mempool.js b/lib/mempool/mempool.js index c78afa08..6fe70bde 100644 --- a/lib/mempool/mempool.js +++ b/lib/mempool/mempool.js @@ -517,11 +517,23 @@ Mempool.prototype.has = function has(hash) { if (this.locker.hasPending(hash)) return true; - if (this.hasOrphan(hash)) + if (hash === this.currentTX) return true; - //if (hash === this.currentTX) - //return true; + return this.exists(hash); +}; + +/** + * Test the mempool to see if it + * contains a transaction or an orphan. + * @private + * @param {Hash} hash + * @returns {Boolean} + */ + +Mempool.prototype.exists = function exists(hash) { + if (this.hasOrphan(hash)) + return true; return this.hasTX(hash); }; @@ -639,7 +651,7 @@ Mempool.prototype._addTX = co(function* _addTX(tx) { 0); } - if (this.has(hash)) { + if (this.exists(hash)) { throw new VerifyError(tx, 'alreadyknown', 'txn-already-in-mempool',