diff --git a/lib/bcoin/walletdb.js b/lib/bcoin/walletdb.js index bdac4d7d..7ae35ff8 100644 --- a/lib/bcoin/walletdb.js +++ b/lib/bcoin/walletdb.js @@ -51,6 +51,7 @@ function WalletDB(options) { this.fees = options.fees; this.logger = options.logger || bcoin.defaultLogger; this.batches = {}; + this.watchers = {}; this.workerPool = null; // We need one read lock for `get` and `create`. @@ -76,8 +77,6 @@ function WalletDB(options) { if (bcoin.useWorkers) this.workerPool = new bcoin.workers(); - this.watchers = {}; - this._init(); } @@ -95,6 +94,12 @@ WalletDB.prototype._init = function _init() { self.emit('error', err); }); + if (bcoin.useWorkers) { + this.workerPool.on('error', function(err) { + self.emit('error', err); + }); + } + function handleEvent(event, tx, map) { var i, path;