diff --git a/lib/bcoin/miner.js b/lib/bcoin/miner.js index 105f8de8..613b57a8 100644 --- a/lib/bcoin/miner.js +++ b/lib/bcoin/miner.js @@ -57,13 +57,6 @@ function Miner(options) { this.attempt = null; this.workerPool = null; - if (bcoin.useWorkers) { - this.workerPool = new bcoin.workers({ - size: this.options.parallel ? 2 : 1, - timeout: -1 - }); - } - this._init(); } @@ -117,6 +110,17 @@ Miner.prototype._init = function _init() { stat.height, stat.best); }); + + if (bcoin.useWorkers) { + this.workerPool = new bcoin.workers({ + size: this.options.parallel ? 2 : 1, + timeout: -1 + }); + + this.workerPool.on('error', function(err) { + self.emit('error', err); + }); + } }; /** @@ -365,6 +369,8 @@ function MinerBlock(options) { this._init(); } +utils.inherits(MinerBlock, EventEmitter); + /** * Initialize the block. * @private @@ -446,8 +452,6 @@ MinerBlock.prototype._init = function _init() { this.updateMerkle(); }; -utils.inherits(MinerBlock, EventEmitter); - /** * Update the commitment output for segwit. */