diff --git a/lib/net/pool.js b/lib/net/pool.js index dba0c932..b8731a40 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -1744,9 +1744,7 @@ Pool.prototype.broadcast = function broadcast(msg) { } return new Promise(function(resolve, reject) { - item.addCallback(function(err) { - resolve(err ? false : true); - }); + item.addCallback(co.wrap(resolve, reject)); }); }; @@ -2534,7 +2532,7 @@ BroadcastItem.prototype.ack = function ack(peer) { self.emit('ack', peer); for (i = 0; i < self.callback.length; i++) - self.callback[i](); + self.callback[i](null, true); self.callback.length = 0; }, 1000); @@ -2546,14 +2544,12 @@ BroadcastItem.prototype.ack = function ack(peer) { */ BroadcastItem.prototype.reject = function reject(peer) { - var i, err; + var i; this.emit('reject', peer); - err = new Error('Rejected by ' + peer.hostname); - for (i = 0; i < this.callback.length; i++) - this.callback[i](err); + this.callback[i](null, false); this.callback.length = 0; }; diff --git a/lib/node/fullnode.js b/lib/node/fullnode.js index 7fc60111..46ebe4b5 100644 --- a/lib/node/fullnode.js +++ b/lib/node/fullnode.js @@ -221,7 +221,7 @@ Fullnode.prototype._init = function _init() { }); this.miner.on('block', function(block) { - self.broadcast(block.toInv()); + self.broadcast(block.toInv()).catch(onError); }); this.walletdb.on('send', function(tx) {