Skip to content

Commit

Permalink
Various small cleanups (#2761)
Browse files Browse the repository at this point in the history
* use AssertLockHeld(cs) instead of relying on comments

* actually use `clsig` in `EnforceBestChainLock()`

* fix log output in `EnforceBestChainLock()`

* drop comments
  • Loading branch information
UdjinM6 authored and panleone committed Nov 5, 2024
1 parent cc7450d commit 149e3e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/llmq/quorums_chainlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void CChainLocksHandler::EnforceBestChainLock()
continue;
}
LogPrintf("CChainLocksHandler::%s -- CLSIG (%s) invalidates block %s\n",
__func__, bestChainLockWithKnownBlock.ToString(), jt->second->GetBlockHash().ToString());
__func__, clsig.ToString(), jt->second->GetBlockHash().ToString());
DoInvalidateBlock(jt->second, false);
}

Expand All @@ -273,7 +273,7 @@ void CChainLocksHandler::EnforceBestChainLock()

CValidationState state;
if (!ActivateBestChain(state)) {
LogPrintf("CChainLocksHandler::UpdatedBlockTip -- ActivateBestChain failed: %s\n", state.GetRejectReason());
LogPrintf("CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, state.GetRejectReason());
// This should not have happened and we are in a state were it's not safe to continue anymore
assert(false);
}
Expand Down
9 changes: 6 additions & 3 deletions src/llmq/quorums_signing_shares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,9 +781,10 @@ void CSigSharesManager::TryRecoverSig(const CQuorumCPtr& quorum, const uint256&
quorumSigningManager->ProcessRecoveredSig(-1, rs, quorum, connman);
}

// cs must be held
void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher>>& sigSharesToRequest)
{
AssertLockHeld(cs);

int64_t now = GetTimeMillis();
const size_t maxRequestsForNode = 32;

Expand Down Expand Up @@ -876,9 +877,10 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std
}
}

// cs must be held
void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares, StaticSaltedHasher>>& sigSharesToSend)
{
AssertLockHeld(cs);

for (auto& p : nodeStates) {
auto nodeId = p.first;
auto& nodeState = p.second;
Expand Down Expand Up @@ -927,9 +929,10 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::u
}
}

// cs must be held
void CSigSharesManager::CollectSigSharesToAnnounce(std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher>>& sigSharesToAnnounce)
{
AssertLockHeld(cs);

std::unordered_set<std::pair<Consensus::LLMQType, uint256>, StaticSaltedHasher> quorumNodesPrepared;

this->sigSharesToAnnounce.ForEach([&](const SigShareKey& sigShareKey, bool) {
Expand Down

0 comments on commit 149e3e3

Please sign in to comment.