Skip to content

Commit

Permalink
Various small cleanups (#2761)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
UdjinM6 committed Mar 11, 2019
1 parent 588eb30 commit fbf0dcb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions qa/rpc-tests/autoix-mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def run_test(self):
self.wait_for_sporks_same()
self.mine_quorum()

print("Test old InstantSend")
self.log.info("Test old InstantSend")
self.test_auto();

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

print("Test new InstantSend")
self.log.info("Test new InstantSend")
self.test_auto(True);

def test_auto(self, new_is = False):
Expand Down
4 changes: 2 additions & 2 deletions qa/rpc-tests/p2p-autoinstantsend.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ def run_test(self):
self.wait_for_sporks_same()
self.mine_quorum()

print("Test old InstantSend")
self.log.info("Test old InstantSend")
self.test_auto();

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

print("Test new InstantSend")
self.log.info("Test new InstantSend")
self.test_auto(True);

def test_auto(self, new_is = False):
Expand Down
4 changes: 2 additions & 2 deletions qa/rpc-tests/p2p-instantsend.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def run_test(self):
self.wait_for_sporks_same()
self.mine_quorum()

print("Test old InstantSend")
self.log.info("Test old InstantSend")
self.test_doublespend()

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

print("Test new InstantSend")
self.log.info("Test new InstantSend")
self.test_doublespend()

def test_doublespend(self):
Expand Down
4 changes: 2 additions & 2 deletions src/llmq/quorums_chainlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,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 @@ -439,7 +439,7 @@ void CChainLocksHandler::EnforceBestChainLock()

CValidationState state;
if (!ActivateBestChain(state, Params())) {
LogPrintf("CChainLocksHandler::UpdatedBlockTip -- ActivateBestChain failed: %s\n", FormatStateMessage(state));
LogPrintf("CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, FormatStateMessage(state));
// 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 @@ -790,9 +790,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 @@ -885,9 +886,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 @@ -936,9 +938,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 fbf0dcb

Please sign in to comment.