Skip to content

Commit 58acea6

Browse files
Merge #6908: refactor: replace size check with is_single_member() method for clarity
90a3b57 refactor: replace size check with is_single_member() method for clarity (pasta) Pull request description: ## Issue being fixed or feature implemented Avoiding using raw size as indication for special logic; use a helper function in-case the conditions change in the future (however unlikely that may be) ## What was done? added helper for `is_single_member` ## How Has This Been Tested? builds ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: knst: utACK 90a3b57 UdjinM6: utACK 90a3b57 Tree-SHA512: 65a5f6babcde2a39397d2ef7242917edcdf38419fe606752cc86e7a6c2a8815c6a7f0eab99997aed4be129c2ae4435cb9b48ed78e451819f0fdd6152ca0357bd
2 parents 2e71a9a + 90a3b57 commit 58acea6

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

src/llmq/commitment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ bool CFinalCommitment::VerifySignatureAsync(CDeterministicMNManager& dmnman, CQu
5151
LogPrint(BCLog::LLMQ, "CFinalCommitment::%s members[%s] quorumPublicKey[%s] commitmentHash[%s]\n", __func__,
5252
ss3.str(), quorumPublicKey.ToString(), commitmentHash.ToString());
5353
}
54-
if (llmq_params.size == 1) {
54+
if (llmq_params.is_single_member()) {
5555
LogPrintf("pubkey operator: %s\n", members[0]->pdmnState->pubKeyOperator.Get().ToString());
5656
if (!membersSig.VerifyInsecure(members[0]->pdmnState->pubKeyOperator.Get(), commitmentHash)) {
5757
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid member signature\n", quorumHash.ToString());
@@ -138,7 +138,7 @@ bool CFinalCommitment::Verify(CDeterministicMNManager& dmnman, CQuorumSnapshotMa
138138
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid quorumPublicKey\n", quorumHash.ToString());
139139
return false;
140140
}
141-
if (llmq_params.size != 1 && quorumVvecHash.IsNull()) {
141+
if (!llmq_params.is_single_member() && quorumVvecHash.IsNull()) {
142142
LogPrint(BCLog::LLMQ, "CFinalCommitment -- q[%s] invalid quorumVvecHash\n", quorumHash.ToString());
143143
return false;
144144
}

src/llmq/dkgsessionhandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ void CDKGSessionHandler::HandleDKGRound(CConnman& connman, PeerManager& peerman)
551551
return changed;
552552
});
553553

554-
if (params.size == 1) {
554+
if (params.is_single_member()) {
555555
auto finalCommitment = curSession->FinalizeSingleCommitment();
556556
if (!finalCommitment.IsNull()) { // it can be null only if we are not member
557557
if (auto inv_opt = quorumBlockProcessor.AddMineableCommitment(finalCommitment); inv_opt.has_value()) {

src/llmq/params.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct LLMQParams {
121121

122122
// For how many blocks recent DKG info should be kept
123123
[[nodiscard]] constexpr int max_store_depth() const { return max_cycles(keepOldKeys) * dkgInterval; }
124+
[[nodiscard]] constexpr bool is_single_member() const { return size == 1; }
124125
};
125126

126127
//static_assert(std::is_trivial_v<Consensus::LLMQParams>, "LLMQParams is not a trivial type");

src/llmq/signing_shares.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ void CSigSharesManager::TryRecoverSig(const CQuorumCPtr& quorum, const uint256&
789789
return;
790790
}
791791

792-
if (quorum->params.size == 1) {
792+
if (quorum->params.is_single_member()) {
793793
if (sigSharesForSignHash->empty()) {
794794
LogPrint(BCLog::LLMQ_SIGS, /* Continued */
795795
"CSigSharesManager::%s -- impossible to recover single-node signature - no shares yet. id=%s, "
@@ -1638,7 +1638,7 @@ std::optional<CSigShare> CSigSharesManager::CreateSigShare(const CQuorumCPtr& qu
16381638
return std::nullopt;
16391639
}
16401640

1641-
if (quorum->params.size == 1) {
1641+
if (quorum->params.is_single_member()) {
16421642
int memberIdx = quorum->GetMemberIndex(activeMasterNodeProTxHash);
16431643
if (memberIdx == -1) {
16441644
// this should really not happen (IsValidMember gave true)

src/rpc/quorums.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_
212212
mo.pushKV("pubKeyOperator", dmn->pdmnState->pubKeyOperator.ToString());
213213
mo.pushKV("valid", static_cast<bool>(quorum->qc->validMembers[i]));
214214
if (quorum->qc->validMembers[i]) {
215-
if (quorum->params.size == 1) {
215+
if (quorum->params.is_single_member()) {
216216
mo.pushKV("pubKeyShare", dmn->pdmnState->pubKeyOperator.ToString());
217217
} else {
218218
CBLSPublicKey pubKey = quorum->GetPubKeyShare(i);

0 commit comments

Comments
 (0)