From b8c9eec34f0be2b09b1c7c82a1633ef418d75625 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 26 Apr 2022 20:22:56 +0300 Subject: [PATCH] llmq: Avoid endless loop in GetQuorumRelayMembers (#4796) * llmq: Avoid endless loop in GetQuorumRelayMembers regtest quorums can be tiny * minimize changes, add a note --- src/llmq/utils.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/llmq/utils.cpp b/src/llmq/utils.cpp index 08c43c1f2a..32ccb34b4e 100644 --- a/src/llmq/utils.cpp +++ b/src/llmq/utils.cpp @@ -588,6 +588,12 @@ std::set CLLMQUtils::GetQuorumRelayMembers(const Consensus::LLMQParams& std::set result; auto calcOutbound = [&](size_t i, const uint256& proTxHash) { + if (mns.size() == 1) { + // No outbound connections are needed when there is one MN only. + // Also note that trying to calculate results via the algorithm below + // would result in an endless loop. + return std::set(); + } // Relay to nodes at indexes (i+2^k)%n, where // k: 0..max(1, floor(log2(n-1))-1) // n: size of the quorum/ring