Skip to content

Commit

Permalink
remove debug comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ohcee committed Aug 1, 2024
1 parent e71b8c5 commit 21489f2
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,15 @@ std::map<libzerocoin::CoinSpend, uint256> cacheSpends;
std::map<libzerocoin::PublicCoin, uint256> cacheMints;
std::map<uint256, uint256> cacheSpentPubcoins;

bool FlushCacheToDatabase(const CBlockIndex* pindex, CValidationState& state) {
LogPrintf("Flushing cache to database. Cache sizes: spends=%d, mints=%d, pubcoins=%d\n", cacheSpends.size(), cacheMints.size(), cacheSpentPubcoins.size());

bool FlushCacheToDatabase(const CBlockIndex* pindex, CValidationState& state) {
if (!pzerocoinDB->WriteCoinSpendBatch(cacheSpends)) {
LogPrintf("Failed to write coin spends to database\n");
return state.Error("Failed to record coin serials to database");
}
if (!pzerocoinDB->WriteCoinMintBatch(cacheMints)) {
LogPrintf("Failed to write coin mints to database\n");
return state.Error("Failed to record new mints to database");
}
if (pindex->nHeight >= Params().HeightLightZerocoin()) {
if (!pzerocoinDB->WritePubcoinSpendBatch(cacheSpentPubcoins, pindex->GetBlockHash())) {
LogPrintf("Failed to write pubcoin spends to database\n");
return state.Error("Failed to record new pubcoinspends to database");
}
}
Expand All @@ -108,37 +103,26 @@ bool FlushCacheToDatabase(const CBlockIndex* pindex, CValidationState& state) {
cacheMints.clear();
cacheSpentPubcoins.clear();

LogPrintf("Cache successfully flushed to database\n");
return true;
}

bool CacheAndFlushZerocoinData(CValidationState& state, const CBlockIndex* pindex, const std::map<libzerocoin::CoinSpend, uint256>& mapSpends, const std::map<libzerocoin::PublicCoin, uint256>& mapMints, const std::map<uint256, uint256>& mapSpentPubcoinsInBlock) {
LogPrintf("Adding %d spends, %d mints, and %d pubcoin spends to cache\n", mapSpends.size(), mapMints.size(), mapSpentPubcoinsInBlock.size());

bool CacheAndFlushZerocoinData(CValidationState& state, const CBlockIndex* pindex, const std::map<libzerocoin::CoinSpend, uint256>& mapSpends, const std::map<libzerocoin::PublicCoin, uint256>& mapMints, const std::map<uint256, uint256>& mapSpentPubcoinsInBlock) {
cacheSpends.insert(mapSpends.begin(), mapSpends.end());
cacheMints.insert(mapMints.begin(), mapMints.end());
if (pindex->nHeight >= Params().HeightLightZerocoin()) {
cacheSpentPubcoins.insert(mapSpentPubcoinsInBlock.begin(), mapSpentPubcoinsInBlock.end());
}

LogPrintf("Cache sizes after insertion: spends=%d, mints=%d, pubcoins=%d\n", cacheSpends.size(), cacheMints.size(), cacheSpentPubcoins.size());

// Check if cache size threshold is reached
if (cacheSpends.size() >= CACHE_SIZE_THRESHOLD || cacheMints.size() >= CACHE_SIZE_THRESHOLD || cacheSpentPubcoins.size() >= CACHE_SIZE_THRESHOLD) {
LogPrintf("Cache size threshold reached, flushing to database\n");
if (!FlushCacheToDatabase(pindex, state)) return false;
}

return true;
}

bool ProcessZerocoinData(CValidationState& state, const CBlockIndex* pindex, const std::map<libzerocoin::CoinSpend, uint256>& mapSpends, const std::map<libzerocoin::PublicCoin, uint256>& mapMints, const std::map<uint256, uint256>& mapSpentPubcoinsInBlock) {
LogPrintf("Processing zerocoin data for block at height %d\n", pindex->nHeight);

bool ProcessZerocoinData(CValidationState& state, const CBlockIndex* pindex, const std::map<libzerocoin::CoinSpend, uint256>& mapSpends, const std::map<libzerocoin::PublicCoin, uint256>& mapMints, const std::map<uint256, uint256>& mapSpentPubcoinsInBlock) {
if (!CacheAndFlushZerocoinData(state, pindex, mapSpends, mapMints, mapSpentPubcoinsInBlock))
return state.Error("Failed to process zerocoin");

LogPrintf("Successfully processed zerocoin data for block at height %d\n", pindex->nHeight);
return true;
}

Expand Down

0 comments on commit 21489f2

Please sign in to comment.