Skip to content

Commit 6348e4b

Browse files
committed
llmq: Move GetVerifiedContribution into GetVerifiedContributions
1 parent 5fdfa26 commit 6348e4b

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/llmq/quorums_dkgsessionmgr.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,26 @@ bool CDKGSessionManager::GetVerifiedContributions(Consensus::LLMQType llmqType,
218218
skContributionsRet.reserve(members.size());
219219
for (size_t i = 0; i < members.size(); i++) {
220220
if (validMembers[i]) {
221-
BLSVerificationVectorPtr vvec;
222-
CBLSSecretKey skContribution;
223-
if (!GetVerifiedContribution(llmqType, pindexQuorum, members[i]->proTxHash, vvec, skContribution)) {
224-
return false;
221+
LOCK(contributionsCacheCs);
222+
const uint256& proTxHash = members[i]->proTxHash;
223+
ContributionsCacheKey cacheKey = {llmqType, pindexQuorum->GetBlockHash(), proTxHash};
224+
auto it = contributionsCache.find(cacheKey);
225+
if (it == contributionsCache.end()) {
226+
BLSVerificationVector vvec;
227+
BLSVerificationVectorPtr vvecPtr;
228+
CBLSSecretKey skContribution;
229+
if (!llmqDb.Read(std::make_tuple(DB_VVEC, llmqType, pindexQuorum->GetBlockHash(), proTxHash), vvec)) {
230+
return false;
231+
}
232+
llmqDb.Read(std::make_tuple(DB_SKCONTRIB, llmqType, pindexQuorum->GetBlockHash(), proTxHash), skContribution);
233+
234+
vvecPtr = std::make_shared<BLSVerificationVector>(std::move(vvec));
235+
it = contributionsCache.emplace(cacheKey, ContributionsCacheEntry{GetTimeMillis(), vvecPtr, skContribution}).first;
225236
}
226237

227238
memberIndexesRet.emplace_back(i);
228-
vvecsRet.emplace_back(vvec);
229-
skContributionsRet.emplace_back(skContribution);
239+
vvecsRet.emplace_back(it->second.vvec);
240+
skContributionsRet.emplace_back(it->second.skContribution);
230241
}
231242
}
232243
return true;

0 commit comments

Comments
 (0)