refactor: minor.

This commit is contained in:
Christopher Jeffrey 2016-09-23 21:36:05 -07:00
parent 6357795fd9
commit 1906034106
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 7 additions and 8 deletions

View File

@ -1009,6 +1009,8 @@ Chain.prototype.isBusy = function isBusy() {
Chain.prototype.add = co(function* add(block) { Chain.prototype.add = co(function* add(block) {
var unlock = yield this.locker.lock(block); var unlock = yield this.locker.lock(block);
assert(!this.currentBlock);
this.currentBlock = block.hash('hex'); this.currentBlock = block.hash('hex');
try { try {

View File

@ -547,25 +547,23 @@ Mempool.prototype.hasReject = function hasReject(hash) {
Mempool.prototype.addTX = co(function* addTX(tx) { Mempool.prototype.addTX = co(function* addTX(tx) {
var unlock = yield this.locker.lock(tx); var unlock = yield this.locker.lock(tx);
var missing;
assert(!this.currentTX);
this.currentTX = tx.hash('hex'); this.currentTX = tx.hash('hex');
try { try {
missing = yield this._addTX(tx); return yield this._addTX(tx);
} catch (err) { } catch (err) {
if (err.type === 'VerifyError') { if (err.type === 'VerifyError') {
if (!tx.hasWitness() && !err.malleated) if (!tx.hasWitness() && !err.malleated)
this.rejects.add(tx.hash()); this.rejects.add(tx.hash());
} }
throw err;
} finally {
this.currentTX = null; this.currentTX = null;
unlock(); unlock();
throw err;
} }
this.currentTX = null;
unlock();
return missing;
}); });
/** /**

View File

@ -1360,7 +1360,6 @@ Pool.prototype._handleTX = co(function* _handleTX(tx, peer) {
if (err.type === 'VerifyError') { if (err.type === 'VerifyError') {
if (err.score !== -1) if (err.score !== -1)
peer.reject(tx, err.code, err.reason, err.score); peer.reject(tx, err.code, err.reason, err.score);
throw err;
} }
throw err; throw err;
} }