From 189cee21086ce0aec391cc8191e3935e3fc8e1ef Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Tue, 22 Jan 2019 14:11:15 +0100 Subject: [PATCH] Don't pass poolSize to SelectQuorum and instead use consensus params --- src/llmq/quorums.cpp | 9 ++++++--- src/llmq/quorums.h | 4 ++-- src/llmq/quorums_signing.cpp | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index fe59bf3b7bcae..8859c06160b44 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -333,14 +333,17 @@ std::vector CQuorumManager::ScanQuorums(Consensus::LLMQType llmqTyp return result; } -CQuorumCPtr CQuorumManager::SelectQuorum(Consensus::LLMQType llmqType, const uint256& selectionHash, size_t poolSize) +CQuorumCPtr CQuorumManager::SelectQuorum(Consensus::LLMQType llmqType, const uint256& selectionHash) { LOCK(cs_main); - return SelectQuorum(llmqType, chainActive.Tip()->GetBlockHash(), selectionHash, poolSize); + return SelectQuorum(llmqType, chainActive.Tip()->GetBlockHash(), selectionHash); } -CQuorumCPtr CQuorumManager::SelectQuorum(Consensus::LLMQType llmqType, const uint256& startBlock, const uint256& selectionHash, size_t poolSize) +CQuorumCPtr CQuorumManager::SelectQuorum(Consensus::LLMQType llmqType, const uint256& startBlock, const uint256& selectionHash) { + auto& llmqParams = Params().GetConsensus().llmqs.at(llmqType); + size_t poolSize = (size_t)llmqParams.signingActiveQuorumCount; + auto quorums = ScanQuorums(llmqType, startBlock, poolSize); if (quorums.empty()) { return nullptr; diff --git a/src/llmq/quorums.h b/src/llmq/quorums.h index 9273dbbcc5051..0fcd6022d368a 100644 --- a/src/llmq/quorums.h +++ b/src/llmq/quorums.h @@ -99,8 +99,8 @@ class CQuorumManager CQuorumCPtr GetNewestQuorum(Consensus::LLMQType llmqType); std::vector ScanQuorums(Consensus::LLMQType llmqType, size_t maxCount); std::vector ScanQuorums(Consensus::LLMQType llmqType, const uint256& startBlock, size_t maxCount); - CQuorumCPtr SelectQuorum(Consensus::LLMQType llmqType, const uint256& selectionHash, size_t poolSize); - CQuorumCPtr SelectQuorum(Consensus::LLMQType llmqType, const uint256& startBlock, const uint256& selectionHash, size_t poolSize); + CQuorumCPtr SelectQuorum(Consensus::LLMQType llmqType, const uint256& selectionHash); + CQuorumCPtr SelectQuorum(Consensus::LLMQType llmqType, const uint256& startBlock, const uint256& selectionHash); private: void EnsureQuorumConnections(Consensus::LLMQType llmqType, const CBlockIndex *pindexNew); diff --git a/src/llmq/quorums_signing.cpp b/src/llmq/quorums_signing.cpp index 6804d20c5a0eb..21eb2c5770eaf 100644 --- a/src/llmq/quorums_signing.cpp +++ b/src/llmq/quorums_signing.cpp @@ -482,7 +482,7 @@ bool CSigningManager::AsyncSignIfMember(Consensus::LLMQType llmqType, const uint // This gives a slight risk of not getting enough shares to recover a signature // But at least it shouldn't be possible to get conflicting recovered signatures // TODO fix this by re-signing when the next block arrives, but only when that block results in a change of the quorum list and no recovered signature has been created in the mean time - CQuorumCPtr quorum = quorumManager->SelectQuorum(llmqType, id, params.signingActiveQuorumCount); + CQuorumCPtr quorum = quorumManager->SelectQuorum(llmqType, id); if (!quorum) { LogPrintf("CSigningManager::%s -- failed to select quorum. id=%s, msgHash=%s\n", __func__, id.ToString(), msgHash.ToString()); return false;