Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if cachedChainTip is null, better to load it from active_chain IMO

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