From 98c975de8b9a0b6f8b07e8547130c87e7720574f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 17 Jul 2017 22:39:11 -0700 Subject: [PATCH] pool: fix `bad orphan` event handling. --- lib/net/pool.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/net/pool.js b/lib/net/pool.js index 67ebffe7..185281c1 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -178,10 +178,18 @@ Pool.prototype._init = function _init() { this.logger.info('Chain is fully synced (height=%d).', this.chain.height); }); + this.chain.on('bad orphan', (err, id) => { + this.handleBadOrphan('block', err, id); + }); + if (this.mempool) { this.mempool.on('tx', (tx) => { this.emit('tx', tx); }); + + this.mempool.on('bad orphan', (err, id) => { + this.handleBadOrphan('tx', err, id); + }); } if (!this.options.selfish && !this.options.spv) { @@ -189,10 +197,6 @@ Pool.prototype._init = function _init() { this.mempool.on('tx', (tx) => { this.announceTX(tx); }); - - this.mempool.on('bad orphan', (err, id) => { - this.handleBadOrphan('tx', err, id); - }); } // Normally we would also broadcast @@ -206,10 +210,6 @@ Pool.prototype._init = function _init() { return; this.announceBlock(block); }); - - this.chain.on('bad orphan', (err, id) => { - this.handleBadOrphan('block', err, id); - }); } };