diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index 7c37eb58d7..ea563985b4 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -105,7 +105,7 @@ CBLSPublicKey CQuorum::GetPubKeyShare(size_t memberIdx) const return blsCache.BuildPubKeyShare(m->proTxHash, quorumVvec, CBLSId(m->proTxHash)); } -CBLSSecretKey CQuorum::GetSkShare() const +const CBLSSecretKey& CQuorum::GetSkShare() const { return skShare; } @@ -286,19 +286,17 @@ bool CQuorumManager::BuildQuorumContributions(const CFinalCommitment& fqc, std:: return false; } - BLSVerificationVectorPtr quorumVvec; - CBLSSecretKey skShare; - cxxtimer::Timer t2(true); - quorumVvec = blsWorker.BuildQuorumVerificationVector(vvecs); - if (quorumVvec == nullptr) { + quorum->quorumVvec = blsWorker.BuildQuorumVerificationVector(vvecs); + if (quorum->quorumVvec == nullptr) { LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- failed to build quorumVvec\n", __func__); // without the quorum vvec, there can't be a skShare, so we fail here. Failure is not fatal here, as it still // allows to use the quorum as a non-member (verification through the quorum pub key) return false; } - skShare = blsWorker.AggregateSecretKeys(skContributions); - if (!skShare.IsValid()) { + quorum->skShare = blsWorker.AggregateSecretKeys(skContributions); + if (!quorum->skShare.IsValid()) { + quorum->skShare.Reset(); LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- failed to build skShare\n", __func__); // We don't bail out here as this is not a fatal error and still allows us to recover public key shares (as we // have a valid quorum vvec at this point) @@ -307,9 +305,6 @@ bool CQuorumManager::BuildQuorumContributions(const CFinalCommitment& fqc, std:: LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- built quorum vvec and skShare. time=%d\n", __func__, t2.count()); - quorum->quorumVvec = quorumVvec; - quorum->skShare = skShare; - return true; } diff --git a/src/llmq/quorums.h b/src/llmq/quorums.h index 43a43465ae..23123315d3 100644 --- a/src/llmq/quorums.h +++ b/src/llmq/quorums.h @@ -165,7 +165,7 @@ public: int GetMemberIndex(const uint256& proTxHash) const; CBLSPublicKey GetPubKeyShare(size_t memberIdx) const; - CBLSSecretKey GetSkShare() const; + const CBLSSecretKey& GetSkShare() const; private: void WriteContributions(CEvoDB& evoDb); diff --git a/src/llmq/quorums_signing_shares.cpp b/src/llmq/quorums_signing_shares.cpp index 0e981ad5e1..8859441d48 100644 --- a/src/llmq/quorums_signing_shares.cpp +++ b/src/llmq/quorums_signing_shares.cpp @@ -1569,7 +1569,7 @@ CSigShare CSigSharesManager::CreateSigShare(const CQuorumCPtr& quorum, const uin return {}; } - CBLSSecretKey skShare = quorum->GetSkShare(); + const CBLSSecretKey& skShare = quorum->GetSkShare(); if (!skShare.IsValid()) { LogPrint(BCLog::LLMQ_SIGS, "CSigSharesManager::%s -- we don't have our skShare for quorum %s\n", __func__, quorum->qc.quorumHash.ToString()); return {}; diff --git a/src/rpc/rpcquorums.cpp b/src/rpc/rpcquorums.cpp index d24eab3943..087d05cfbb 100644 --- a/src/rpc/rpcquorums.cpp +++ b/src/rpc/rpcquorums.cpp @@ -111,7 +111,7 @@ UniValue BuildQuorumInfo(const llmq::CQuorumCPtr& quorum, bool includeMembers, b ret.pushKV("members", membersArr); } ret.pushKV("quorumPublicKey", quorum->qc.quorumPublicKey.ToString()); - CBLSSecretKey skShare = quorum->GetSkShare(); + const CBLSSecretKey& skShare = quorum->GetSkShare(); if (includeSkShare && skShare.IsValid()) { ret.pushKV("secretKeyShare", skShare.ToString()); }