From a667caec13dc224ece5715ebb0dcb0969285cd04 Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Mon, 13 Jun 2016 13:02:46 -0600 Subject: [PATCH] Ensure mempool integrity checks don't trip on chained joinsplits. --- src/txmempool.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 0a202229a..edffcec78 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -314,14 +314,28 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const assert(it3->second.n == i); i++; } + + boost::unordered_map intermediates; + BOOST_FOREACH(const CPourTx &pour, tx.vpour) { BOOST_FOREACH(const uint256 &serial, pour.serials) { assert(!pcoins->GetSerial(serial)); } - // TODO: chained pours ZCIncrementalMerkleTree tree; - assert(pcoins->GetAnchorAt(pour.anchor, tree)); + auto it = intermediates.find(pour.anchor); + if (it != intermediates.end()) { + tree = it->second; + } else { + assert(pcoins->GetAnchorAt(pour.anchor, tree)); + } + + BOOST_FOREACH(const uint256& commitment, pour.commitments) + { + tree.append(commitment); + } + + intermediates.insert(std::make_pair(tree.root(), tree)); } if (fDependsWait) waitingOnDependants.push_back(&it->second);