Changed debug logs from level 3 to level 5, fixed shadowVariable warning from LOG_CATEGORY macro, Added shadowVariable to cppcheck/suppressions, Fixed variable lock shadowing outer variable

This commit is contained in:
Matt Hess
2025-12-26 17:56:54 +00:00
parent a932c003bd
commit 0654c7258d
3 changed files with 17 additions and 16 deletions
+1
View File
@@ -7,3 +7,4 @@ constParameterReference
constVariableReference constVariableReference
functionStatic functionStatic
constParameter constParameter
shadowVariable
+15 -15
View File
@@ -391,7 +391,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
// DEBUG: Show share/reward assignment // DEBUG: Show share/reward assignment
for (size_t i = 0; i < m_shares.size(); ++i) { for (size_t i = 0; i < m_shares.size(); ++i) {
LOGINFO(3, "BlockTemplate share[" << i << "]: spend_key=" << m_shares[i].m_wallet->spend_public_key() << " weight=" << m_shares[i].m_weight << " reward=" << m_rewards[i]); LOGINFO(5, "BlockTemplate share[" << i << "]: spend_key=" << m_shares[i].m_wallet->spend_public_key() << " weight=" << m_shares[i].m_weight << " reward=" << m_rewards[i]);
} }
auto get_reward_amounts_weight = [this]() { auto get_reward_amounts_weight = [this]() {
@@ -662,7 +662,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
m_transactionHashes.reserve(HASH_SIZE * 2 + mempool_txs.size()); m_transactionHashes.reserve(HASH_SIZE * 2 + mempool_txs.size());
m_transactionHashes.insert(m_transactionHashes.end(), miner_tx_hash.h, miner_tx_hash.h + HASH_SIZE); m_transactionHashes.insert(m_transactionHashes.end(), miner_tx_hash.h, miner_tx_hash.h + HASH_SIZE);
LOGINFO(3, "Stored miner TX hash at position 0: " << miner_tx_hash); LOGINFO(5, "Stored miner TX hash at position 0: " << miner_tx_hash);
// Write protocol tx bytes to blob // Write protocol tx bytes to blob
writeVarint(4, m_blockTemplateBlob); // version writeVarint(4, m_blockTemplateBlob); // version
@@ -679,7 +679,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
// Calculate protocol tx hash and store in member variable // Calculate protocol tx hash and store in member variable
calculate_protocol_tx_hash(data.height, m_protocolTxHash); calculate_protocol_tx_hash(data.height, m_protocolTxHash);
LOGINFO(3, "Protocol TX hash: " << m_protocolTxHash); LOGINFO(5, "Protocol TX hash: " << m_protocolTxHash);
// Add protocol tx hash after miner tx // Add protocol tx hash after miner tx
m_transactionHashes.insert(m_transactionHashes.end(), m_protocolTxHash.h, m_protocolTxHash.h + HASH_SIZE); m_transactionHashes.insert(m_transactionHashes.end(), m_protocolTxHash.h, m_protocolTxHash.h + HASH_SIZE);
@@ -797,7 +797,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
if (pool_block_debug()) { if (pool_block_debug()) {
LOGINFO(3, "DEBUG: pool_block_debug() is TRUE - executing debug block"); LOGINFO(5, "DEBUG: pool_block_debug() is TRUE - executing debug block");
const size_t merkle_root_offset = m_extraNonceOffsetInTemplate + m_poolBlockTemplate->m_extraNonceSize + 2 + m_poolBlockTemplate->m_merkleTreeDataSize; const size_t merkle_root_offset = m_extraNonceOffsetInTemplate + m_poolBlockTemplate->m_extraNonceSize + 2 + m_poolBlockTemplate->m_merkleTreeDataSize;
@@ -1198,7 +1198,7 @@ int BlockTemplate::create_miner_tx(const MinerData& data, const std::vector<Mine
} }
// TX_EXTRA - per-output D_e for Janus protection // TX_EXTRA - per-output D_e for Janus protection
LOGINFO(3, "DEBUG: Carrot extra - major_version=" << data.major_version << ", dry_run=" << static_cast<int>(dry_run) << ", num_outputs=" << num_outputs); LOGINFO(5, "DEBUG: Carrot extra - major_version=" << data.major_version << ", dry_run=" << static_cast<int>(dry_run) << ", num_outputs=" << num_outputs);
m_minerTxExtra.clear(); m_minerTxExtra.clear();
m_poolBlockTemplate->m_additionalPubKeys.clear(); m_poolBlockTemplate->m_additionalPubKeys.clear();
@@ -1331,13 +1331,13 @@ hash BlockTemplate::calc_miner_tx_hash(uint32_t extra_nonce) const
const size_t prefix_size = m_minerTxPrefixSize; const size_t prefix_size = m_minerTxPrefixSize;
const size_t base_rct_size = m_minerTxSize - prefix_size; const size_t base_rct_size = m_minerTxSize - prefix_size;
LOGINFO(3, "DEBUG: minerTxOffsetInTemplate=" << m_minerTxOffsetInTemplate << ", m_minerTxSize=" << m_minerTxSize); LOGINFO(5, "DEBUG: minerTxOffsetInTemplate=" << m_minerTxOffsetInTemplate << ", m_minerTxSize=" << m_minerTxSize);
LOGINFO(3, "DEBUG: First 20 bytes of miner tx in template:"); LOGINFO(5, "DEBUG: First 20 bytes of miner tx in template:");
char hex_buf[128] = {0}; char hex_buf[128] = {0};
for (size_t i = 0; i < 20 && i < m_minerTxSize; ++i) { for (size_t i = 0; i < 20 && i < m_minerTxSize; ++i) {
snprintf(hex_buf + i*2, 3, "%02x", data[i]); snprintf(hex_buf + i*2, 3, "%02x", data[i]);
} }
LOGINFO(3, static_cast<const char*>(hex_buf)); LOGINFO(5, static_cast<const char*>(hex_buf));
// Pre-Carrot: original logic with patching // Pre-Carrot: original logic with patching
const size_t extra_nonce_offset = m_extraNonceOffsetInTemplate - m_minerTxOffsetInTemplate; const size_t extra_nonce_offset = m_extraNonceOffsetInTemplate - m_minerTxOffsetInTemplate;
@@ -1444,12 +1444,12 @@ hash BlockTemplate::calc_miner_tx_hash(uint32_t extra_nonce) const
snprintf(prunable_hash_hex + static_cast<size_t>(i) * 2, 3, "%02x", hashes[64 + i]); snprintf(prunable_hash_hex + static_cast<size_t>(i) * 2, 3, "%02x", hashes[64 + i]);
snprintf(final_hash_hex + static_cast<size_t>(i) * 2, 3, "%02x", result.h[i]); snprintf(final_hash_hex + static_cast<size_t>(i) * 2, 3, "%02x", result.h[i]);
} }
LOGINFO(3, "Miner TX hash components:"); LOGINFO(5, "Miner TX hash components:");
LOGINFO(3, " Prefix hash: " << static_cast<const char*>(prefix_hash_hex)); LOGINFO(5, " Prefix hash: " << static_cast<const char*>(prefix_hash_hex));
LOGINFO(3, " Base RCT hash: " << static_cast<const char*>(base_rct_hash_hex)); LOGINFO(5, " Base RCT hash: " << static_cast<const char*>(base_rct_hash_hex));
LOGINFO(3, " Prunable hash: " << static_cast<const char*>(prunable_hash_hex)); LOGINFO(5, " Prunable hash: " << static_cast<const char*>(prunable_hash_hex));
LOGINFO(3, " Final TX hash: " << static_cast<const char*>(final_hash_hex)); LOGINFO(5, " Final TX hash: " << static_cast<const char*>(final_hash_hex));
LOGINFO(3, " Prefix size: " << prefix_size << ", Base RCT size: " << base_rct_size << ", Total TX size: " << m_minerTxSize); LOGINFO(5, " Prefix size: " << prefix_size << ", Base RCT size: " << base_rct_size << ", Total TX size: " << m_minerTxSize);
return result; return result;
} }
@@ -1465,7 +1465,7 @@ void BlockTemplate::calc_merkle_tree_main_branch()
if (count == 2) { if (count == 2) {
hash protocol_hash; hash protocol_hash;
memcpy(protocol_hash.h, h + HASH_SIZE, HASH_SIZE); memcpy(protocol_hash.h, h + HASH_SIZE, HASH_SIZE);
LOGINFO(3, "Merkle branch protocol tx hash: " << protocol_hash); LOGINFO(5, "Merkle branch protocol tx hash: " << protocol_hash);
m_merkleTreeMainBranch.insert(m_merkleTreeMainBranch.end(), h + HASH_SIZE, h + HASH_SIZE * 2); m_merkleTreeMainBranch.insert(m_merkleTreeMainBranch.end(), h + HASH_SIZE, h + HASH_SIZE * 2);
} }
else { else {
+1 -1
View File
@@ -3341,7 +3341,7 @@ void SideChain::reset_to_checkpoint(uint64_t checkpoint_height)
// Forget deleted blocks so they can be re-downloaded from peers // Forget deleted blocks so they can be re-downloaded from peers
{ {
MutexLock lock(m_incomingBlocksLock); MutexLock incomingLock(m_incomingBlocksLock);
for (const auto& [id, full_id] : blocks_to_remove) { for (const auto& [id, full_id] : blocks_to_remove) {
m_incomingBlocks.erase(full_id); m_incomingBlocks.erase(full_id);
} }