@@ -31,7 +31,7 @@ static const std::string DB_QUORUM_QUORUM_VVEC = "q_Qqvvec";
31
31
32
32
CQuorumManager* quorumManager;
33
33
34
- CCriticalSection cs_data_requests;
34
+ Mutex cs_data_requests;
35
35
static std::unordered_map<std::pair<uint256, bool >, CQuorumDataRequest, StaticSaltedHasher> mapQuorumDataRequests GUARDED_BY (cs_data_requests);
36
36
37
37
static uint256 MakeQuorumKey (const CQuorum& q)
@@ -285,7 +285,6 @@ void CQuorumManager::EnsureQuorumConnections(const Consensus::LLMQParams& llmqPa
285
285
286
286
CQuorumPtr CQuorumManager::BuildQuorumFromCommitment (const Consensus::LLMQType llmqType, const CBlockIndex* pQuorumBaseBlockIndex) const
287
287
{
288
- AssertLockHeld (quorumsCacheCs);
289
288
assert (pQuorumBaseBlockIndex);
290
289
291
290
const uint256& quorumHash{pQuorumBaseBlockIndex->GetBlockHash ()};
@@ -321,7 +320,7 @@ CQuorumPtr CQuorumManager::BuildQuorumFromCommitment(const Consensus::LLMQType l
321
320
StartCachePopulatorThread (quorum);
322
321
}
323
322
324
- mapQuorumsCache[llmqType].insert (quorumHash, quorum);
323
+ WITH_LOCK (quorumsCacheCs, mapQuorumsCache[llmqType].insert (quorumHash, quorum) );
325
324
326
325
return quorum;
327
326
}
@@ -336,20 +335,22 @@ bool CQuorumManager::BuildQuorumContributions(const CFinalCommitmentPtr& fqc, co
336
335
}
337
336
338
337
cxxtimer::Timer t2 (true );
339
- LOCK (quorum->cs );
340
- quorum->quorumVvec = blsWorker.BuildQuorumVerificationVector (vvecs);
341
- if (!quorum->HasVerificationVector ()) {
342
- LogPrint (BCLog::LLMQ, " CQuorumManager::%s -- failed to build quorumVvec\n " , __func__);
343
- // without the quorum vvec, there can't be a skShare, so we fail here. Failure is not fatal here, as it still
344
- // allows to use the quorum as a non-member (verification through the quorum pub key)
345
- return false ;
346
- }
347
- quorum->skShare = blsWorker.AggregateSecretKeys (skContributions);
348
- if (!quorum->skShare .IsValid ()) {
349
- quorum->skShare .Reset ();
350
- LogPrint (BCLog::LLMQ, " CQuorumManager::%s -- failed to build skShare\n " , __func__);
351
- // We don't bail out here as this is not a fatal error and still allows us to recover public key shares (as we
352
- // have a valid quorum vvec at this point)
338
+ {
339
+ LOCK (quorum->cs );
340
+ quorum->quorumVvec = blsWorker.BuildQuorumVerificationVector (vvecs);
341
+ if (!quorum->HasVerificationVector ()) {
342
+ LogPrint (BCLog::LLMQ, " CQuorumManager::%s -- failed to build quorumVvec\n " , __func__);
343
+ // without the quorum vvec, there can't be a skShare, so we fail here. Failure is not fatal here, as it still
344
+ // allows to use the quorum as a non-member (verification through the quorum pub key)
345
+ return false ;
346
+ }
347
+ quorum->skShare = blsWorker.AggregateSecretKeys (skContributions);
348
+ if (!quorum->skShare .IsValid ()) {
349
+ quorum->skShare .Reset ();
350
+ LogPrint (BCLog::LLMQ, " CQuorumManager::%s -- failed to build skShare\n " , __func__);
351
+ // We don't bail out here as this is not a fatal error and still allows us to recover public key shares (as we
352
+ // have a valid quorum vvec at this point)
353
+ }
353
354
}
354
355
t2.stop ();
355
356
@@ -493,9 +494,8 @@ CQuorumCPtr CQuorumManager::GetQuorum(Consensus::LLMQType llmqType, const CBlock
493
494
return nullptr ;
494
495
}
495
496
496
- LOCK (quorumsCacheCs);
497
497
CQuorumPtr pQuorum;
498
- if (mapQuorumsCache[llmqType].get (quorumHash, pQuorum)) {
498
+ if (WITH_LOCK (quorumsCacheCs, return mapQuorumsCache[llmqType].get (quorumHash, pQuorum) )) {
499
499
return pQuorum;
500
500
}
501
501
@@ -649,12 +649,9 @@ void CQuorumManager::ProcessMessage(CNode* pFrom, const std::string& strCommand,
649
649
}
650
650
651
651
CQuorumPtr pQuorum;
652
- {
653
- LOCK (quorumsCacheCs);
654
- if (!mapQuorumsCache[request.GetLLMQType ()].get (request.GetQuorumHash (), pQuorum)) {
655
- errorHandler (" Quorum not found" , 0 ); // Don't bump score because we asked for it
656
- return ;
657
- }
652
+ if (LOCK (quorumsCacheCs); !mapQuorumsCache[request.GetLLMQType ()].get (request.GetQuorumHash (), pQuorum)) {
653
+ errorHandler (" Quorum not found" , 0 ); // Don't bump score because we asked for it
654
+ return ;
658
655
}
659
656
660
657
// Check if request has QUORUM_VERIFICATION_VECTOR data
0 commit comments