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:
+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
|
||||
|
||||
Reference in New Issue
Block a user