Skip to content

Commit ecfbcfd

Browse files
committed
[Cleanup] Remove unused function AddInvalidSpendsToMap
mapInvalidOutPoints and mapInvalidSerials are only written, never read. AddInvalidSpendsToMap is also buggy, as it keeps a pointer to a local variable after it goes out of scope.
1 parent 15b018c commit ecfbcfd

File tree

1 file changed

+0
-67
lines changed

1 file changed

+0
-67
lines changed

src/validation.cpp

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -998,68 +998,6 @@ bool CScriptCheck::operator()()
998998
return VerifyScript(scriptSig, scriptPubKey, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, amount, cacheStore, *precomTxData), ptxTo->GetRequiredSigVersion(), &error);
999999
}
10001000

1001-
std::map<COutPoint, COutPoint> mapInvalidOutPoints;
1002-
std::map<CBigNum, CAmount> mapInvalidSerials;
1003-
void AddInvalidSpendsToMap(const CBlock& block)
1004-
{
1005-
libzerocoin::ZerocoinParams* params = Params().GetConsensus().Zerocoin_Params(false);
1006-
for (const auto& txIn : block.vtx) {
1007-
const CTransaction tx = *txIn;
1008-
if (!tx.ContainsZerocoins())
1009-
continue;
1010-
1011-
//Check all zerocoinspends for bad serials
1012-
for (const CTxIn& in : tx.vin) {
1013-
bool isPublicSpend = in.IsZerocoinPublicSpend();
1014-
if (in.IsZerocoinSpend() || isPublicSpend) {
1015-
1016-
libzerocoin::CoinSpend* spend;
1017-
if (isPublicSpend) {
1018-
PublicCoinSpend publicSpend(params);
1019-
CValidationState state;
1020-
if (!ZPIVModule::ParseZerocoinPublicSpend(in, tx, state, publicSpend)){
1021-
throw std::runtime_error("Failed to parse public spend");
1022-
}
1023-
spend = &publicSpend;
1024-
} else {
1025-
libzerocoin::CoinSpend spendObj = TxInToZerocoinSpend(in);
1026-
spend = &spendObj;
1027-
}
1028-
1029-
//If serial is not valid, mark all outputs as bad
1030-
if (!spend->HasValidSerial(params)) {
1031-
mapInvalidSerials[spend->getCoinSerialNumber()] = spend->getDenomination() * COIN;
1032-
1033-
// Derive the actual valid serial from the invalid serial if possible
1034-
CBigNum bnActualSerial = spend->CalculateValidSerial(params);
1035-
uint256 txHash;
1036-
1037-
if (zerocoinDB->ReadCoinSpend(bnActualSerial, txHash)) {
1038-
mapInvalidSerials[bnActualSerial] = spend->getDenomination() * COIN;
1039-
1040-
CTransactionRef txPrev;
1041-
uint256 hashBlock;
1042-
if (!GetTransaction(txHash, txPrev, hashBlock, true))
1043-
continue;
1044-
1045-
//Record all txouts from txPrev as invalid
1046-
for (unsigned int i = 0; i < txPrev->vout.size(); i++) {
1047-
//map to an empty outpoint to represent that this is the first in the chain of bad outs
1048-
mapInvalidOutPoints[COutPoint(txPrev->GetHash(), i)] = COutPoint();
1049-
}
1050-
}
1051-
1052-
//Record all txouts from this invalid zerocoin spend tx as invalid
1053-
for (unsigned int i = 0; i < tx.vout.size(); i++) {
1054-
//map to an empty outpoint to represent that this is the first in the chain of bad outs
1055-
mapInvalidOutPoints[COutPoint(tx.GetHash(), i)] = COutPoint();
1056-
}
1057-
}
1058-
}
1059-
}
1060-
}
1061-
}
1062-
10631001
bool ValidOutPoint(const COutPoint& out, int nHeight)
10641002
{
10651003
bool isInvalid = nHeight >= Params().GetConsensus().height_start_InvalidUTXOsCheck && invalid_out::ContainsOutPoint(out);
@@ -1775,11 +1713,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
17751713
nTimeCallbacks += nTime4 - nTime3;
17761714
LogPrint(BCLog::BENCH, " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001);
17771715

1778-
//Continue tracking possible movement of fraudulent funds until they are completely frozen
1779-
if (pindex->nHeight >= consensus.height_start_ZC_InvalidSerials &&
1780-
pindex->nHeight <= consensus.height_ZC_RecalcAccumulators + 1)
1781-
AddInvalidSpendsToMap(block);
1782-
17831716
if (consensus.NetworkUpgradeActive(pindex->nHeight, Consensus::UPGRADE_ZC_V2) &&
17841717
pindex->nHeight < consensus.height_last_ZC_AccumCheckpoint) {
17851718
// Legacy Zerocoin DB: If Accumulators Checkpoint is changed, database the checksums

0 commit comments

Comments
 (0)