Skip to content

Commit fbf0dcb

Browse files
authored
Various small cleanups (#2761)
* Fix remaining `print`s in tests * use AssertLockHeld(cs) instead of relying on comments * actually use `clsig` in `EnforceBestChainLock()` * fix log output in `EnforceBestChainLock()` * drop comments
1 parent 588eb30 commit fbf0dcb

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

qa/rpc-tests/autoix-mempool.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ def run_test(self):
127127
self.wait_for_sporks_same()
128128
self.mine_quorum()
129129

130-
print("Test old InstantSend")
130+
self.log.info("Test old InstantSend")
131131
self.test_auto();
132132

133133
self.nodes[0].spork("SPORK_20_INSTANTSEND_LLMQ_BASED", 0)
134134
self.wait_for_sporks_same()
135135

136-
print("Test new InstantSend")
136+
self.log.info("Test new InstantSend")
137137
self.test_auto(True);
138138

139139
def test_auto(self, new_is = False):

qa/rpc-tests/p2p-autoinstantsend.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ def run_test(self):
121121
self.wait_for_sporks_same()
122122
self.mine_quorum()
123123

124-
print("Test old InstantSend")
124+
self.log.info("Test old InstantSend")
125125
self.test_auto();
126126

127127
self.nodes[0].spork("SPORK_20_INSTANTSEND_LLMQ_BASED", 0)
128128
self.wait_for_sporks_same()
129129

130-
print("Test new InstantSend")
130+
self.log.info("Test new InstantSend")
131131
self.test_auto(True);
132132

133133
def test_auto(self, new_is = False):

qa/rpc-tests/p2p-instantsend.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def run_test(self):
2525
self.wait_for_sporks_same()
2626
self.mine_quorum()
2727

28-
print("Test old InstantSend")
28+
self.log.info("Test old InstantSend")
2929
self.test_doublespend()
3030

3131
self.nodes[0].spork("SPORK_20_INSTANTSEND_LLMQ_BASED", 0)
3232
self.wait_for_sporks_same()
3333

34-
print("Test new InstantSend")
34+
self.log.info("Test new InstantSend")
3535
self.test_doublespend()
3636

3737
def test_doublespend(self):

src/llmq/quorums_chainlocks.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void CChainLocksHandler::EnforceBestChainLock()
428428
continue;
429429
}
430430
LogPrintf("CChainLocksHandler::%s -- CLSIG (%s) invalidates block %s\n",
431-
__func__, bestChainLockWithKnownBlock.ToString(), jt->second->GetBlockHash().ToString());
431+
__func__, clsig.ToString(), jt->second->GetBlockHash().ToString());
432432
DoInvalidateBlock(jt->second, false);
433433
}
434434

@@ -439,7 +439,7 @@ void CChainLocksHandler::EnforceBestChainLock()
439439

440440
CValidationState state;
441441
if (!ActivateBestChain(state, Params())) {
442-
LogPrintf("CChainLocksHandler::UpdatedBlockTip -- ActivateBestChain failed: %s\n", FormatStateMessage(state));
442+
LogPrintf("CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, FormatStateMessage(state));
443443
// This should not have happened and we are in a state were it's not safe to continue anymore
444444
assert(false);
445445
}

src/llmq/quorums_signing_shares.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -790,9 +790,10 @@ void CSigSharesManager::TryRecoverSig(const CQuorumCPtr& quorum, const uint256&
790790
quorumSigningManager->ProcessRecoveredSig(-1, rs, quorum, connman);
791791
}
792792

793-
// cs must be held
794793
void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher>>& sigSharesToRequest)
795794
{
795+
AssertLockHeld(cs);
796+
796797
int64_t now = GetTimeMillis();
797798
const size_t maxRequestsForNode = 32;
798799

@@ -885,9 +886,10 @@ void CSigSharesManager::CollectSigSharesToRequest(std::unordered_map<NodeId, std
885886
}
886887
}
887888

888-
// cs must be held
889889
void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::unordered_map<uint256, CBatchedSigShares, StaticSaltedHasher>>& sigSharesToSend)
890890
{
891+
AssertLockHeld(cs);
892+
891893
for (auto& p : nodeStates) {
892894
auto nodeId = p.first;
893895
auto& nodeState = p.second;
@@ -936,9 +938,10 @@ void CSigSharesManager::CollectSigSharesToSend(std::unordered_map<NodeId, std::u
936938
}
937939
}
938940

939-
// cs must be held
940941
void CSigSharesManager::CollectSigSharesToAnnounce(std::unordered_map<NodeId, std::unordered_map<uint256, CSigSharesInv, StaticSaltedHasher>>& sigSharesToAnnounce)
941942
{
943+
AssertLockHeld(cs);
944+
942945
std::unordered_set<std::pair<Consensus::LLMQType, uint256>, StaticSaltedHasher> quorumNodesPrepared;
943946

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

0 commit comments

Comments
 (0)