Skip to content

Commit

Permalink
actually use cachedChainTip
Browse files Browse the repository at this point in the history
  • Loading branch information
PastaPastaPasta committed Nov 21, 2024
1 parent 6cae4a5 commit a8ed736
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/llmq/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,17 +1206,22 @@ CQuorumCPtr CQuorumManager::SelectQuorumForSigning(const Consensus::LLMQParams&
{
size_t poolSize = llmq_params.signingActiveQuorumCount;

CBlockIndex* pindexStart;
auto pindexStart = [&]() -> const CBlockIndex*
{
LOCK(cs_main);
auto chainTip = cachedChainTip.load();
if (chainTip == nullptr) return nullptr;
auto cur_height = chainTip->nHeight;
if (signHeight == -1) {
signHeight = active_chain.Height();
signHeight = cur_height;
}
int startBlockHeight = signHeight - signOffset;
if (startBlockHeight > active_chain.Height() || startBlockHeight < 0) {
return {};
if (startBlockHeight > cur_height || startBlockHeight < 0) {
return nullptr;
}
pindexStart = active_chain[startBlockHeight];
return chainTip->GetAncestor(startBlockHeight);
}();
if (pindexStart == nullptr) {
return {};
}

if (IsQuorumRotationEnabled(llmq_params, pindexStart)) {
Expand Down

0 comments on commit a8ed736

Please sign in to comment.