message: Fixed zerocoin-related mempool checks
diff: @@ -419,12 +419,14 @@ bool CTxMemPool::addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry,
  mapTx.modify(newit, update_fee_delta(deltas.second));
  }
  }
  - if (!entry.GetTx().IsZerocoinSpend()) {
  +
  // Update cachedInnerUsage to include contained transaction's usage.
  // (When we update the entry for in-mempool parents, memory usage will be
  // further updated.)
  cachedInnerUsage += entry.DynamicMemoryUsage();
  + if (!entry.GetTx().IsZerocoinSpend()) {
  +
  const CTransaction &tx = newit->GetTx();
  std::set <uint256> setParentTransactions;
  for (unsigned int i = 0; i < tx.vin.size(); i++) {
  @@ -448,12 +450,13 @@ bool CTxMemPool::addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry,
  }
  UpdateAncestorsOf(true, newit, setAncestors);
  UpdateEntryForAncestors(newit, setAncestors);
  - totalTxSize += entry.GetTxSize();
  minerPolicyEstimator->processTransaction(entry, fCurrentEstimate);
  vTxHashes.emplace_back(tx.GetWitnessHash(), newit);
  newit->vTxHashesIdx = vTxHashes.size() - 1;
  }
  + totalTxSize += entry.GetTxSize();
  +
  nTransactionsUpdated++;
  return true;
  @@ -473,11 +476,11 @@ void CTxMemPool::removeUnchecked(txiter it) {
  vTxHashes.shrink_to_fit();
  } else
  vTxHashes.clear();
  + }
  - totalTxSize -= it->GetTxSize();
  cachedInnerUsage -= it->DynamicMemoryUsage();
  cachedInnerUsage -= memusage::DynamicUsage(mapLinks[it].parents) + memusage::DynamicUsage(mapLinks[it].children);
  - }
  + totalTxSize -= it->GetTxSize();
  mapLinks.erase(it);
  mapTx.erase(it);
  @@ -821,11 +824,13 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const {
  txlinksMap::const_iterator linksiter = mapLinks.find(it);
  assert(linksiter != mapLinks.end());
  const TxLinks &links = linksiter->second;
  + if (!tx.IsZerocoinSpend())
  innerUsage += memusage::DynamicUsage(links.parents) + memusage::DynamicUsage(links.children);
  bool fDependsWait = false;
  setEntries setParentCheck;
  int64_t parentSizes = 0;
  int64_t parentSigOpCost = 0;
  + if (!tx.IsZerocoinSpend()) {
  BOOST_FOREACH(
  const CTxIn &txin, tx.vin) {
  // Check that every mempool transaction's inputs refer to available coins, or other mempool tx's.
  @@ -849,6 +854,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const {
  assert(it3->second == &tx);
  i++;
  }
  + }
  assert(setParentCheck == GetMemPoolParents(it));
  // Verify ancestor state is correct.
  setEntries setAncestors;
  