Check for locks in more places in CSigSharesManager

This commit is contained in:
UdjinM6 2021-06-23 11:07:45 +03:00
parent cf3896304a
commit 66f3f4f328
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9

View File

@ -599,6 +599,7 @@ void CSigSharesManager::CollectPendingSigSharesToVerify(
}
auto& sigShare = *ns.pendingIncomingSigShares.GetFirst();
AssertLockHeld(cs);
bool alreadyHave = this->sigShares.Has(sigShare.GetKey());
if (!alreadyHave) {
uniqueSignHashes.emplace(nodeId, sigShare.GetSignHash());
@ -1068,6 +1069,7 @@ void CSigSharesManager::CollectSigSharesToAnnounce(std::unordered_map<NodeId, st
std::unordered_map<std::pair<Consensus::LLMQType, uint256>, std::unordered_set<NodeId>, StaticSaltedHasher> quorumNodesMap;
sigSharesQueuedToAnnounce.ForEach([&](const SigShareKey& sigShareKey, bool) {
AssertLockHeld(cs);
auto& signHash = sigShareKey.first;
auto quorumMember = sigShareKey.second;
const CSigShare* sigShare = sigShares.Get(sigShareKey);
@ -1428,6 +1430,7 @@ void CSigSharesManager::Cleanup()
}
// remove global requested state to force a re-request from another node
it->second.requestedSigShares.ForEach([&](const SigShareKey& k, bool) {
AssertLockHeld(cs);
sigSharesRequested.Erase(k);
});
nodeStates.erase(nodeId);
@ -1462,6 +1465,7 @@ void CSigSharesManager::RemoveBannedNodeStates()
if (IsBanned(it->first)) {
// re-request sigshares from other nodes
it->second.requestedSigShares.ForEach([&](const SigShareKey& k, int64_t) {
AssertLockHeld(cs);
sigSharesRequested.Erase(k);
});
it = nodeStates.erase(it);
@ -1491,6 +1495,7 @@ void CSigSharesManager::BanNode(NodeId nodeId)
// Whatever we requested from him, let's request it from someone else now
nodeState.requestedSigShares.ForEach([&](const SigShareKey& k, int64_t) {
AssertLockHeld(cs);
sigSharesRequested.Erase(k);
});
nodeState.requestedSigShares.Clear();