@@ -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