From ca4e938a7509bbec7f7352cf2f22d78be408ab86 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 26 Sep 2017 20:22:54 -0700 Subject: [PATCH] mempool: fix orphan resolution edge case. --- lib/mempool/mempool.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/mempool/mempool.js b/lib/mempool/mempool.js index aae2755a..04cb55cd 100644 --- a/lib/mempool/mempool.js +++ b/lib/mempool/mempool.js @@ -1562,7 +1562,16 @@ Mempool.prototype.handleOrphans = async function handleOrphans(parent) { throw err; } - assert(!missing || missing.length === 0); + // Can happen if an existing parent is + // evicted in the interim between fetching + // the non-present parents. + if (missing && missing.length > 0) { + this.logger.debug( + 'Transaction %s was double-orphaned in mempool.', + tx.txid()); + this.removeOrphan(tx.hash('hex')); + continue; + } this.logger.debug('Resolved orphan %s in mempool.', tx.txid()); }