miner: fix miner.stop().
This commit is contained in:
parent
6ee7ac8a51
commit
719222b61d
@ -178,6 +178,8 @@ Miner.prototype.start = function start(version) {
|
||||
|
||||
attempt.mineAsync(function(err, block) {
|
||||
if (err) {
|
||||
if (!self.running)
|
||||
return;
|
||||
self.emit('error', err);
|
||||
return self.start();
|
||||
}
|
||||
@ -363,6 +365,8 @@ function MinerBlock(options) {
|
||||
this.witness = options.witness;
|
||||
this.address = options.address;
|
||||
this.network = bcoin.network.get(options.network);
|
||||
this.timeout = null;
|
||||
this.callback = null;
|
||||
|
||||
this.coinbase = new bcoin.tx();
|
||||
this.coinbase.mutable = true;
|
||||
@ -673,6 +677,10 @@ MinerBlock.prototype.mineAsync = function mine(callback) {
|
||||
if (!this.workerPool)
|
||||
return this.mine(callback);
|
||||
|
||||
callback = utils.once(callback);
|
||||
|
||||
this.callback = callback;
|
||||
|
||||
function done(err, block) {
|
||||
self.workerPool.destroy();
|
||||
callback(err, block);
|
||||
@ -697,6 +705,10 @@ MinerBlock.prototype.destroy = function destroy() {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = null;
|
||||
}
|
||||
if (this.callback) {
|
||||
this.callback(new Error('Destroyed.'));
|
||||
this.callback = null;
|
||||
}
|
||||
this.block = null;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user