diff --git a/src/llmq/quorums_utils.cpp b/src/llmq/quorums_utils.cpp index 76583b960..e9c69cec3 100644 --- a/src/llmq/quorums_utils.cpp +++ b/src/llmq/quorums_utils.cpp @@ -50,10 +50,13 @@ std::set CLLMQUtils::GetQuorumConnections(Consensus::LLMQType llmqType for (size_t i = 0; i < mns.size(); i++) { auto& dmn = mns[i]; if (dmn->proTxHash == forMember) { - // Connect to nodes at indexes (i+2^k)%n, k: 0..floor(log2(n-1))-1, n: size of the quorum/ring + // Connect to nodes at indexes (i+2^k)%n, where + // k: 0..max(1, floor(log2(n-1))-1) + // n: size of the quorum/ring int gap = 1; - int gap_max = mns.size() - 1; - while (gap_max >>= 1) { + int gap_max = (int)mns.size() - 1; + int k = 0; + while ((gap_max >>= 1) || k <= 1) { size_t idx = (i + gap) % mns.size(); auto& otherDmn = mns[idx]; if (otherDmn == dmn) { @@ -61,6 +64,7 @@ std::set CLLMQUtils::GetQuorumConnections(Consensus::LLMQType llmqType } result.emplace(otherDmn->pdmnState->addr); gap <<= 1; + k++; } // there can be no two members with the same proTxHash, so return early break;