From 1906034106d43dac19f81f7fbcce19642de98e22 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 23 Sep 2016 21:36:05 -0700 Subject: [PATCH] refactor: minor. --- lib/chain/chain.js | 2 ++ lib/mempool/mempool.js | 12 +++++------- lib/net/pool.js | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/chain/chain.js b/lib/chain/chain.js index 369f43f7..66699f06 100644 --- a/lib/chain/chain.js +++ b/lib/chain/chain.js @@ -1009,6 +1009,8 @@ Chain.prototype.isBusy = function isBusy() { Chain.prototype.add = co(function* add(block) { var unlock = yield this.locker.lock(block); + assert(!this.currentBlock); + this.currentBlock = block.hash('hex'); try { diff --git a/lib/mempool/mempool.js b/lib/mempool/mempool.js index cce49559..11ba3d95 100644 --- a/lib/mempool/mempool.js +++ b/lib/mempool/mempool.js @@ -547,25 +547,23 @@ Mempool.prototype.hasReject = function hasReject(hash) { Mempool.prototype.addTX = co(function* addTX(tx) { var unlock = yield this.locker.lock(tx); - var missing; + + assert(!this.currentTX); this.currentTX = tx.hash('hex'); try { - missing = yield this._addTX(tx); + return yield this._addTX(tx); } catch (err) { if (err.type === 'VerifyError') { if (!tx.hasWitness() && !err.malleated) this.rejects.add(tx.hash()); } + throw err; + } finally { this.currentTX = null; unlock(); - throw err; } - - this.currentTX = null; - unlock(); - return missing; }); /** diff --git a/lib/net/pool.js b/lib/net/pool.js index 0b293338..0a4cbf74 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -1360,7 +1360,6 @@ Pool.prototype._handleTX = co(function* _handleTX(tx, peer) { if (err.type === 'VerifyError') { if (err.score !== -1) peer.reject(tx, err.code, err.reason, err.score); - throw err; } throw err; }