mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
refactor: minimize GetLLMQParams calls (#5211)
## Issue being fixed or feature implemented Avoid redundant calls to GetLLMQParams ## What was done? ## How Has This Been Tested? ## Breaking Changes ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **For repository code-owners and collaborators only** - [x] I have assigned this pull request to a milestone
This commit is contained in:
parent
0ee3974d1f
commit
9f4d431b52
@ -97,7 +97,7 @@ std::string CBatchedSigShares::ToInvString() const
|
||||
|
||||
static void InitSession(CSigSharesNodeState::Session& s, const uint256& signHash, CSigBase from)
|
||||
{
|
||||
const auto& llmq_params = GetLLMQParams((Consensus::LLMQType)from.getLlmqType());
|
||||
const auto& llmq_params = GetLLMQParams(from.getLlmqType());
|
||||
|
||||
s.llmqType = from.getLlmqType();
|
||||
s.quorumHash = from.getQuorumHash();
|
||||
|
@ -35,7 +35,7 @@ namespace utils
|
||||
{
|
||||
// Forward declarations
|
||||
static std::vector<CDeterministicMNCPtr> ComputeQuorumMembers(Consensus::LLMQType llmqType, const CBlockIndex* pQuorumBaseBlockIndex);
|
||||
static std::vector<std::vector<CDeterministicMNCPtr>> ComputeQuorumMembersByQuarterRotation(Consensus::LLMQType llmqType, const CBlockIndex* pCycleQuorumBaseBlockIndex);
|
||||
static std::vector<std::vector<CDeterministicMNCPtr>> ComputeQuorumMembersByQuarterRotation(const Consensus::LLMQParams& llmqParams, const CBlockIndex* pCycleQuorumBaseBlockIndex);
|
||||
|
||||
static std::vector<std::vector<CDeterministicMNCPtr>> BuildNewQuorumQuarterMembers(const Consensus::LLMQParams& llmqParams, const CBlockIndex* pQuorumBaseBlockIndex, const PreviousQuorumQuarters& quarters);
|
||||
|
||||
@ -112,7 +112,7 @@ std::vector<CDeterministicMNCPtr> GetAllQuorumMembers(Consensus::LLMQType llmqTy
|
||||
return quorumMembers;
|
||||
}
|
||||
|
||||
auto q = ComputeQuorumMembersByQuarterRotation(llmqType, pCycleQuorumBaseBlockIndex);
|
||||
auto q = ComputeQuorumMembersByQuarterRotation(llmqParams, pCycleQuorumBaseBlockIndex);
|
||||
LOCK(cs_indexed_members);
|
||||
for (const size_t i : irange::range(q.size())) {
|
||||
mapIndexedQuorumMembers[llmqType].insert(std::make_pair(pCycleQuorumBaseBlockIndex->GetBlockHash(), i), q[i]);
|
||||
@ -136,9 +136,9 @@ std::vector<CDeterministicMNCPtr> ComputeQuorumMembers(Consensus::LLMQType llmqT
|
||||
return allMns.CalculateQuorum(GetLLMQParams(llmqType).size, modifier, HPMNOnly);
|
||||
}
|
||||
|
||||
std::vector<std::vector<CDeterministicMNCPtr>> ComputeQuorumMembersByQuarterRotation(Consensus::LLMQType llmqType, const CBlockIndex* pCycleQuorumBaseBlockIndex)
|
||||
std::vector<std::vector<CDeterministicMNCPtr>> ComputeQuorumMembersByQuarterRotation(const Consensus::LLMQParams& llmqParams, const CBlockIndex* pCycleQuorumBaseBlockIndex)
|
||||
{
|
||||
const Consensus::LLMQParams& llmqParams = GetLLMQParams(llmqType);
|
||||
const Consensus::LLMQType llmqType = llmqParams.type;
|
||||
|
||||
const int cycleLength = llmqParams.dkgInterval;
|
||||
assert(pCycleQuorumBaseBlockIndex->nHeight % cycleLength == 0);
|
||||
@ -610,12 +610,14 @@ bool IsQuorumRotationEnabled(Consensus::LLMQType llmqType, const CBlockIndex* pi
|
||||
{
|
||||
assert(pindex);
|
||||
|
||||
if (!GetLLMQParams(llmqType).useRotation) {
|
||||
const auto& llmqParams = GetLLMQParams(llmqType);
|
||||
|
||||
if (!llmqParams.useRotation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LOCK(cs_llmq_vbc);
|
||||
int cycleQuorumBaseHeight = pindex->nHeight - (pindex->nHeight % GetLLMQParams(llmqType).dkgInterval);
|
||||
int cycleQuorumBaseHeight = pindex->nHeight - (pindex->nHeight % llmqParams.dkgInterval);
|
||||
if (cycleQuorumBaseHeight < 1) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user