refactor: Compute work from headers without CBlockIndex

Avoid the need to construct a CBlockIndex object just to compute work for a header,
when its nBits value suffices for that.

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
This commit is contained in:
Daniela Brozzoni
2025-08-18 11:46:04 +02:00
parent 0bf6139e19
commit 4066bfe561
5 changed files with 16 additions and 9 deletions

View File

@@ -202,7 +202,7 @@ bool HeadersSyncState::ValidateAndProcessSingleHeader(const CBlockHeader& curren
}
}
m_current_chain_work += GetBlockProof(CBlockIndex(current));
m_current_chain_work += GetBlockProof(current);
m_last_header_received = current;
m_current_height = next_height;
@@ -238,7 +238,7 @@ bool HeadersSyncState::ValidateAndStoreRedownloadedHeader(const CBlockHeader& he
}
// Track work on the redownloaded chain
m_redownload_chain_work += GetBlockProof(CBlockIndex(header));
m_redownload_chain_work += GetBlockProof(header);
if (m_redownload_chain_work >= m_minimum_required_work) {
m_process_all_remaining_headers = true;