fix commit hash caching. fix miner race conditon.

This commit is contained in:
Christopher Jeffrey 2016-06-01 23:16:05 -07:00
parent b0c36d51dc
commit a09c7365aa
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 8 additions and 7 deletions

View File

@ -339,16 +339,15 @@ Block.prototype.__defineGetter__('commitmentHash', function() {
commitment = coinbase.outputs[i].script; commitment = coinbase.outputs[i].script;
if (commitment.isCommitment()) { if (commitment.isCommitment()) {
commitmentHash = commitment.getCommitmentHash(); commitmentHash = commitment.getCommitmentHash();
commitmentHash = commitmentHash.toString('hex');
break; break;
} }
} }
if (!this.mutable) { if (!this.mutable)
if (commitmentHash) this._commitmentHash = commitmentHash;
this._commitmentHash = commitmentHash.toString('hex');
}
return this._commitmentHash; return commitmentHash;
}); });
/** /**

View File

@ -100,13 +100,15 @@ Miner.prototype._init = function _init() {
this.mempool.on('tx', function(tx) { this.mempool.on('tx', function(tx) {
if (!self.running) if (!self.running)
return; return;
self.attempt.addTX(tx); if (self.attempt)
self.attempt.addTX(tx);
}); });
} else if (this.pool) { } else if (this.pool) {
this.pool.on('tx', function(tx) { this.pool.on('tx', function(tx) {
if (!self.running) if (!self.running)
return; return;
self.attempt.addTX(tx); if (self.attempt)
self.attempt.addTX(tx);
}); });
} }