Fixed implicit widening multiplication error, Removed unused "this", Fixed narrowing conversion, Made m_verified and m_invalid mutable, Removed else-after-return, Removed unused num_full_blocks and last_block_size var all to make clang-tidy happy
This commit is contained in:
@@ -1431,10 +1431,10 @@ hash BlockTemplate::calc_miner_tx_hash(uint32_t extra_nonce) const
|
||||
char prunable_hash_hex[65] = {0};
|
||||
char final_hash_hex[65] = {0};
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
snprintf(prefix_hash_hex + i*2, 3, "%02x", hashes[i]);
|
||||
snprintf(base_rct_hash_hex + i*2, 3, "%02x", hashes[32 + i]);
|
||||
snprintf(prunable_hash_hex + i*2, 3, "%02x", hashes[64 + i]);
|
||||
snprintf(final_hash_hex + i*2, 3, "%02x", result.h[i]);
|
||||
snprintf(prefix_hash_hex + static_cast<size_t>(i) * 2, 3, "%02x", hashes[i]);
|
||||
snprintf(base_rct_hash_hex + static_cast<size_t>(i) * 2, 3, "%02x", hashes[32 + 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]);
|
||||
}
|
||||
LOGINFO(3, "Miner TX hash components:");
|
||||
LOGINFO(3, " Prefix hash: " << static_cast<const char*>(prefix_hash_hex));
|
||||
|
||||
+1
-1
@@ -3158,7 +3158,7 @@ bool P2PServer::P2PClient::on_genesis_info(const uint8_t* buf)
|
||||
if (!server->find_block(peer_genesis_id)) {
|
||||
LOGINFO(5, "Requesting genesis block " << peer_genesis_id << " from peer");
|
||||
const bool result = server->send(this,
|
||||
[&peer_genesis_id, this](uint8_t* buf, size_t buf_size) -> size_t
|
||||
[&peer_genesis_id](uint8_t* buf, size_t buf_size) -> size_t
|
||||
{
|
||||
if (buf_size < 1 + HASH_SIZE) {
|
||||
return 0;
|
||||
|
||||
+3
-3
@@ -1976,7 +1976,7 @@ void p2pool::prefetch_mainchain_blocks(uint64_t current_height)
|
||||
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block_headers_range\",\"params\":{\"start_height\":" << start_height << ",\"end_height\":" << (current_height - 1) << "}}" << '\0';
|
||||
|
||||
JSONRPCRequest::call(host.m_address, host.m_rpcPort, buf, host.m_rpcLogin, m_params->m_socks5Proxy, host.m_rpcSSL, host.m_rpcSSL_Fingerprint,
|
||||
[this, start_height, current_height](const char* data, size_t size, double) {
|
||||
[this](const char* data, size_t size, double) {
|
||||
const uint32_t parsed = parse_block_headers_range(data, size);
|
||||
if (parsed > 0) {
|
||||
LOGINFO(1, "Pre-fetched " << parsed << " mainchain blocks into cache");
|
||||
@@ -1984,7 +1984,7 @@ void p2pool::prefetch_mainchain_blocks(uint64_t current_height)
|
||||
LOGWARN(1, "Failed to pre-fetch mainchain blocks, will rely on ZMQ");
|
||||
}
|
||||
},
|
||||
[this](const char* data, size_t size, double) {
|
||||
[](const char* data, size_t size, double) {
|
||||
if (size > 0) {
|
||||
LOGWARN(1, "Failed to pre-fetch mainchain blocks: " << log::const_buf(data, size));
|
||||
}
|
||||
@@ -2021,7 +2021,7 @@ void p2pool::fetch_mainchain_block(uint64_t height)
|
||||
LOGWARN(3, "Failed to parse block header for height " << height);
|
||||
}
|
||||
},
|
||||
[this, height](const char* data, size_t size, double) {
|
||||
[height](const char* data, size_t size, double) {
|
||||
if (size > 0) {
|
||||
LOGWARN(3, "Failed to fetch mainchain block at height " << height << ": " << log::const_buf(data, size));
|
||||
}
|
||||
|
||||
+2
-2
@@ -174,8 +174,8 @@ struct PoolBlock
|
||||
// Just temporary stuff, not a part of the block
|
||||
uint64_t m_depth;
|
||||
|
||||
bool m_verified;
|
||||
bool m_invalid;
|
||||
mutable bool m_verified;
|
||||
mutable bool m_invalid;
|
||||
|
||||
mutable bool m_broadcasted;
|
||||
mutable bool m_wantBroadcast;
|
||||
|
||||
@@ -34,7 +34,7 @@ void calculate_protocol_tx_hash(uint64_t height, hash& result) {
|
||||
hash prefix_hash, base_rct_hash;
|
||||
uint8_t rct_type = 0;
|
||||
|
||||
keccak(prefix_serialized.data(), prefix_serialized.size(), prefix_hash.h);
|
||||
keccak(prefix_serialized.data(), static_cast<int>(prefix_serialized.size()), prefix_hash.h);
|
||||
keccak(&rct_type, 1, base_rct_hash.h);
|
||||
|
||||
// Combine: prefix_hash + base_rct_hash + null_hash (32 zeros)
|
||||
|
||||
+23
-25
@@ -73,10 +73,10 @@ SideChain::SideChain(p2pool* pool, NetworkType type, const char* pool_name, cons
|
||||
, m_chainWindowSize(2160)
|
||||
, m_unclePenalty(20)
|
||||
, m_precalcFinished(false)
|
||||
, m_externalBlockFailures(0)
|
||||
#ifdef DEV_TEST_SYNC
|
||||
, m_firstPruneTime(0)
|
||||
#endif
|
||||
, m_externalBlockFailures(0)
|
||||
{
|
||||
if (s_networkType == NetworkType::Invalid) {
|
||||
s_networkType = type;
|
||||
@@ -3417,8 +3417,7 @@ bool SideChain::validate_loaded_checkpoints()
|
||||
// No checkpoints - need to bootstrap from chain tip
|
||||
const PoolBlock* tip = m_chainTip;
|
||||
if (tip && !tip->m_verified) {
|
||||
PoolBlock* mutable_tip = const_cast<PoolBlock*>(tip);
|
||||
mutable_tip->m_verified = true;
|
||||
tip->m_verified = true;
|
||||
LOGINFO(1, "No checkpoints - bootstrapping verification from chain tip height " << tip->m_sidechainHeight);
|
||||
}
|
||||
return true; // Safe to mine
|
||||
@@ -3443,7 +3442,7 @@ bool SideChain::validate_loaded_checkpoints()
|
||||
LOGINFO(3, "Checkpoint at height " << cp.height << " is reachable, looking up block id " << cp.id);
|
||||
|
||||
// Direct lookup - sidechain lock held above
|
||||
const PoolBlock* found = nullptr;
|
||||
PoolBlock* found = nullptr;
|
||||
auto it = m_blocksById.find(cp.id);
|
||||
if (it != m_blocksById.end()) {
|
||||
found = it->second;
|
||||
@@ -3457,7 +3456,7 @@ bool SideChain::validate_loaded_checkpoints()
|
||||
return false; // NOT safe to mine yet
|
||||
}
|
||||
|
||||
PoolBlock* block = const_cast<PoolBlock*>(found);
|
||||
PoolBlock* block = found;
|
||||
|
||||
if (block->m_sidechainId != cp.id) {
|
||||
LOGWARN(0, "CHECKPOINT MISMATCH at height " << cp.height <<
|
||||
@@ -3489,8 +3488,7 @@ bool SideChain::validate_loaded_checkpoints()
|
||||
if (m_checkpoints.empty()) {
|
||||
const PoolBlock* tip = m_chainTip;
|
||||
if (tip) {
|
||||
PoolBlock* mutable_tip = const_cast<PoolBlock*>(tip);
|
||||
mutable_tip->m_verified = true;
|
||||
tip->m_verified = true;
|
||||
LOGINFO(1, "All checkpoints stale - bootstrapping verification from chain tip height " << tip->m_sidechainHeight);
|
||||
need_bootstrap = true;
|
||||
bootstrap_height = tip->m_sidechainHeight;
|
||||
@@ -3544,25 +3542,25 @@ bool SideChain::validate_loaded_checkpoints()
|
||||
save_checkpoints(); // Persist the cleaned list
|
||||
}
|
||||
return true; // Safe to mine
|
||||
} else {
|
||||
LOGERR(0, "Cached checkpoints are INVALID - chain has diverged since last run");
|
||||
LOGERR(0, "First mismatch at height " << first_mismatch_height);
|
||||
|
||||
{
|
||||
WriteLock wlock(m_checkpointsLock);
|
||||
m_checkpoints.clear();
|
||||
}
|
||||
|
||||
LOGINFO(0, "Cleared stale checkpoints - will rebuild from current chain");
|
||||
save_checkpoints(); // Persist the cleared state
|
||||
|
||||
// Rebuild checkpoints from current chain
|
||||
const PoolBlock* tip = m_chainTip;
|
||||
if (tip) {
|
||||
update_checkpoints(tip->m_sidechainHeight);
|
||||
}
|
||||
return true; // Checkpoints cleared and rebuilt, safe to mine
|
||||
}
|
||||
|
||||
LOGERR(0, "Cached checkpoints are INVALID - chain has diverged since last run");
|
||||
LOGERR(0, "First mismatch at height " << first_mismatch_height);
|
||||
|
||||
{
|
||||
WriteLock wlock(m_checkpointsLock);
|
||||
m_checkpoints.clear();
|
||||
}
|
||||
|
||||
LOGINFO(0, "Cleared stale checkpoints - will rebuild from current chain");
|
||||
save_checkpoints(); // Persist the cleared state
|
||||
|
||||
// Rebuild checkpoints from current chain
|
||||
const PoolBlock* tip = m_chainTip;
|
||||
if (tip) {
|
||||
update_checkpoints(tip->m_sidechainHeight);
|
||||
}
|
||||
return true; // Checkpoints cleared and rebuilt, safe to mine
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
+2
-4
@@ -42,8 +42,6 @@ constexpr uint64_t valid_prefixes[] = { 0x180c96, 0x254c96, 0x24cc96 }; // SC1,
|
||||
constexpr uint64_t valid_prefixes_subaddress[] = { 0x314c96, 0x3c54c96, 0x384cc96 }; // SC1s, SC1Ts, SC1Ss
|
||||
|
||||
constexpr std::array<int, 9> block_sizes{ 0, 2, 3, 5, 6, 7, 9, 10, 11 };
|
||||
constexpr int num_full_blocks = p2pool::Wallet::ADDRESS_LENGTH / block_sizes.back();
|
||||
constexpr int last_block_size = p2pool::Wallet::ADDRESS_LENGTH % block_sizes.back();
|
||||
|
||||
constexpr int block_sizes_lookup[11] = { 0, -1, 1, 2, -1, 3, 4, 5, -1, 6, 7 };
|
||||
|
||||
@@ -127,8 +125,8 @@ bool Wallet::decode(const char* address)
|
||||
}
|
||||
|
||||
// Calculate based on actual address length
|
||||
const int actual_num_full_blocks = addr_len / block_sizes.back();
|
||||
const int actual_last_block_size = addr_len % block_sizes.back();
|
||||
const int actual_num_full_blocks = static_cast<int>(addr_len / block_sizes.back());
|
||||
const int actual_last_block_size = static_cast<int>(addr_len % block_sizes.back());
|
||||
const int actual_last_block_size_index = block_sizes_lookup[actual_last_block_size];
|
||||
|
||||
if (actual_last_block_size_index < 0) {
|
||||
|
||||
Reference in New Issue
Block a user