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