Add some const
s
This commit is contained in:
parent
0b1347c0d3
commit
8b7771a311
@ -33,7 +33,7 @@ double justifyLieRate = 0;
|
||||
double commitOmitRate = 0;
|
||||
double commitLieRate = 0;
|
||||
|
||||
CDKGLogger::CDKGLogger(CDKGSession& _quorumDkg, const std::string& _func) :
|
||||
CDKGLogger::CDKGLogger(const CDKGSession& _quorumDkg, const std::string& _func) :
|
||||
CDKGLogger(_quorumDkg.params.type, _quorumDkg.quorumHash, _quorumDkg.height, _quorumDkg.AreWeMember(), _func)
|
||||
{
|
||||
}
|
||||
@ -178,7 +178,7 @@ void CDKGSession::SendContributions(CDKGPendingMessages& pendingMessages)
|
||||
}
|
||||
|
||||
// only performs cheap verifications, but not the signature of the message. this is checked with batched verification
|
||||
bool CDKGSession::PreVerifyMessage(const uint256& hash, const CDKGContribution& qc, bool& retBan)
|
||||
bool CDKGSession::PreVerifyMessage(const uint256& hash, const CDKGContribution& qc, bool& retBan) const
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
|
||||
@ -271,7 +271,7 @@ void CDKGSession::ReceiveMessage(const uint256& hash, const CDKGContribution& qc
|
||||
receivedVvecs[member->idx] = qc.vvec;
|
||||
|
||||
int receivedCount = 0;
|
||||
for (auto& m : members) {
|
||||
for (const auto& m : members) {
|
||||
if (!m->contributions.empty()) {
|
||||
receivedCount++;
|
||||
}
|
||||
@ -341,7 +341,7 @@ void CDKGSession::VerifyPendingContributions()
|
||||
std::vector<BLSVerificationVectorPtr> vvecs;
|
||||
BLSSecretKeyVector skContributions;
|
||||
|
||||
for (auto& idx : pend) {
|
||||
for (const auto& idx : pend) {
|
||||
auto& m = members[idx];
|
||||
if (m->bad || m->weComplain) {
|
||||
continue;
|
||||
@ -394,7 +394,7 @@ void CDKGSession::VerifyAndComplain(CDKGPendingMessages& pendingMessages)
|
||||
|
||||
cxxtimer::Timer t1(true);
|
||||
|
||||
for (auto& m : members) {
|
||||
for (const auto& m : members) {
|
||||
if (m->bad) {
|
||||
continue;
|
||||
}
|
||||
@ -454,7 +454,7 @@ void CDKGSession::SendComplaint(CDKGPendingMessages& pendingMessages)
|
||||
}
|
||||
|
||||
// only performs cheap verifications, but not the signature of the message. this is checked with batched verification
|
||||
bool CDKGSession::PreVerifyMessage(const uint256& hash, const CDKGComplaint& qc, bool& retBan)
|
||||
bool CDKGSession::PreVerifyMessage(const uint256& hash, const CDKGComplaint& qc, bool& retBan) const
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
|
||||
@ -573,7 +573,7 @@ void CDKGSession::VerifyAndJustify(CDKGPendingMessages& pendingMessages)
|
||||
|
||||
std::set<uint256> justifyFor;
|
||||
|
||||
for (auto& m : members) {
|
||||
for (const auto& m : members) {
|
||||
if (m->bad) {
|
||||
continue;
|
||||
}
|
||||
@ -652,7 +652,7 @@ void CDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, const
|
||||
}
|
||||
|
||||
// only performs cheap verifications, but not the signature of the message. this is checked with batched verification
|
||||
bool CDKGSession::PreVerifyMessage(const uint256& hash, const CDKGJustification& qj, bool& retBan)
|
||||
bool CDKGSession::PreVerifyMessage(const uint256& hash, const CDKGJustification& qj, bool& retBan) const
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
|
||||
@ -803,7 +803,7 @@ void CDKGSession::ReceiveMessage(const uint256& hash, const CDKGJustification& q
|
||||
int receivedCount = 0;
|
||||
int expectedCount = 0;
|
||||
|
||||
for (auto& m : members) {
|
||||
for (const auto& m : members) {
|
||||
if (!m->justifications.empty()) {
|
||||
receivedCount++;
|
||||
}
|
||||
@ -827,7 +827,7 @@ void CDKGSession::VerifyAndCommit(CDKGPendingMessages& pendingMessages)
|
||||
std::vector<size_t> badMembers;
|
||||
std::vector<size_t> openComplaintMembers;
|
||||
|
||||
for (auto& m : members) {
|
||||
for (const auto& m : members) {
|
||||
if (m->bad) {
|
||||
badMembers.emplace_back(m->idx);
|
||||
continue;
|
||||
@ -843,13 +843,13 @@ void CDKGSession::VerifyAndCommit(CDKGPendingMessages& pendingMessages)
|
||||
}
|
||||
if (!badMembers.empty()) {
|
||||
logger.Batch(" members previously determined as bad:");
|
||||
for (auto& idx : badMembers) {
|
||||
for (const auto& idx : badMembers) {
|
||||
logger.Batch(" %s", members[idx]->dmn->proTxHash.ToString());
|
||||
}
|
||||
}
|
||||
if (!openComplaintMembers.empty()) {
|
||||
logger.Batch(" members with open complaints and now marked as bad:");
|
||||
for (auto& idx : openComplaintMembers) {
|
||||
for (const auto& idx : openComplaintMembers) {
|
||||
logger.Batch(" %s", members[idx]->dmn->proTxHash.ToString());
|
||||
}
|
||||
}
|
||||
@ -974,7 +974,7 @@ void CDKGSession::SendCommitment(CDKGPendingMessages& pendingMessages)
|
||||
}
|
||||
|
||||
// only performs cheap verifications, but not the signature of the message. this is checked with batched verification
|
||||
bool CDKGSession::PreVerifyMessage(const uint256& hash, const CDKGPrematureCommitment& qc, bool& retBan)
|
||||
bool CDKGSession::PreVerifyMessage(const uint256& hash, const CDKGPrematureCommitment& qc, bool& retBan) const
|
||||
{
|
||||
CDKGLogger logger(*this, __func__);
|
||||
|
||||
@ -1110,7 +1110,7 @@ void CDKGSession::ReceiveMessage(const uint256& hash, const CDKGPrematureCommitm
|
||||
});
|
||||
|
||||
int receivedCount = 0;
|
||||
for (auto& m : members) {
|
||||
for (const auto& m : members) {
|
||||
if (!m->prematureCommitments.empty()) {
|
||||
receivedCount++;
|
||||
}
|
||||
@ -1134,7 +1134,7 @@ std::vector<CFinalCommitment> CDKGSession::FinalizeCommitments()
|
||||
typedef std::vector<bool> Key;
|
||||
std::map<Key, std::vector<CDKGPrematureCommitment>> commitmentsMap;
|
||||
|
||||
for (auto& p : prematureCommitments) {
|
||||
for (const auto& p : prematureCommitments) {
|
||||
auto& qc = p.second;
|
||||
if (!validCommitments.count(p.first)) {
|
||||
continue;
|
||||
@ -1218,7 +1218,7 @@ std::vector<CFinalCommitment> CDKGSession::FinalizeCommitments()
|
||||
return finalCommitments;
|
||||
}
|
||||
|
||||
CDKGMember* CDKGSession::GetMember(const uint256& proTxHash)
|
||||
CDKGMember* CDKGSession::GetMember(const uint256& proTxHash) const
|
||||
{
|
||||
auto it = membersMap.find(proTxHash);
|
||||
if (it == membersMap.end()) {
|
||||
@ -1248,14 +1248,14 @@ void CDKGSession::AddParticipatingNode(NodeId nodeId)
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto& inv : invSet) {
|
||||
for (const auto& inv : invSet) {
|
||||
pnode->PushInventory(inv);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void CDKGSession::RelayInvToParticipants(const CInv& inv)
|
||||
void CDKGSession::RelayInvToParticipants(const CInv& inv) const
|
||||
{
|
||||
LOCK(invCs);
|
||||
g_connman->ForEachNode([&](CNode* pnode) {
|
||||
|
@ -30,7 +30,7 @@ class CDKGPendingMessages;
|
||||
class CDKGLogger : public CBatchedLogger
|
||||
{
|
||||
public:
|
||||
CDKGLogger(CDKGSession& _quorumDkg, const std::string& _func);
|
||||
CDKGLogger(const CDKGSession& _quorumDkg, const std::string& _func);
|
||||
CDKGLogger(Consensus::LLMQType _llmqType, const uint256& _quorumHash, int _height, bool _areWeMember, const std::string& _func);
|
||||
};
|
||||
|
||||
@ -310,26 +310,26 @@ public:
|
||||
// Phase 1: contribution
|
||||
void Contribute(CDKGPendingMessages& pendingMessages);
|
||||
void SendContributions(CDKGPendingMessages& pendingMessages);
|
||||
bool PreVerifyMessage(const uint256& hash, const CDKGContribution& qc, bool& retBan);
|
||||
bool PreVerifyMessage(const uint256& hash, const CDKGContribution& qc, bool& retBan) const;
|
||||
void ReceiveMessage(const uint256& hash, const CDKGContribution& qc, bool& retBan);
|
||||
void VerifyPendingContributions();
|
||||
|
||||
// Phase 2: complaint
|
||||
void VerifyAndComplain(CDKGPendingMessages& pendingMessages);
|
||||
void SendComplaint(CDKGPendingMessages& pendingMessages);
|
||||
bool PreVerifyMessage(const uint256& hash, const CDKGComplaint& qc, bool& retBan);
|
||||
bool PreVerifyMessage(const uint256& hash, const CDKGComplaint& qc, bool& retBan) const;
|
||||
void ReceiveMessage(const uint256& hash, const CDKGComplaint& qc, bool& retBan);
|
||||
|
||||
// Phase 3: justification
|
||||
void VerifyAndJustify(CDKGPendingMessages& pendingMessages);
|
||||
void SendJustification(CDKGPendingMessages& pendingMessages, const std::set<uint256>& forMembers);
|
||||
bool PreVerifyMessage(const uint256& hash, const CDKGJustification& qj, bool& retBan);
|
||||
bool PreVerifyMessage(const uint256& hash, const CDKGJustification& qj, bool& retBan) const;
|
||||
void ReceiveMessage(const uint256& hash, const CDKGJustification& qj, bool& retBan);
|
||||
|
||||
// Phase 4: commit
|
||||
void VerifyAndCommit(CDKGPendingMessages& pendingMessages);
|
||||
void SendCommitment(CDKGPendingMessages& pendingMessages);
|
||||
bool PreVerifyMessage(const uint256& hash, const CDKGPrematureCommitment& qc, bool& retBan);
|
||||
bool PreVerifyMessage(const uint256& hash, const CDKGPrematureCommitment& qc, bool& retBan) const;
|
||||
void ReceiveMessage(const uint256& hash, const CDKGPrematureCommitment& qc, bool& retBan);
|
||||
|
||||
// Phase 5: aggregate/finalize
|
||||
@ -339,10 +339,10 @@ public:
|
||||
void MarkBadMember(size_t idx);
|
||||
|
||||
void AddParticipatingNode(NodeId nodeId);
|
||||
void RelayInvToParticipants(const CInv& inv);
|
||||
void RelayInvToParticipants(const CInv& inv) const;
|
||||
|
||||
public:
|
||||
CDKGMember* GetMember(const uint256& proTxHash);
|
||||
CDKGMember* GetMember(const uint256& proTxHash) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ bool CDKGSessionHandler::InitNewQuorum(int height, const uint256& quorumHash)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::pair<QuorumPhase, uint256> CDKGSessionHandler::GetPhaseAndQuorumHash()
|
||||
std::pair<QuorumPhase, uint256> CDKGSessionHandler::GetPhaseAndQuorumHash() const
|
||||
{
|
||||
LOCK(cs);
|
||||
return std::make_pair(phase, quorumHash);
|
||||
@ -495,7 +495,7 @@ void CDKGSessionHandler::HandleDKGRound()
|
||||
}
|
||||
if (!connections.empty()) {
|
||||
std::string debugMsg = strprintf("CDKGSessionManager::%s -- adding masternodes quorum connections for quorum %s:\n", __func__, curSession->quorumHash.ToString());
|
||||
for (auto& c : connections) {
|
||||
for (const auto& c : connections) {
|
||||
debugMsg += strprintf(" %s\n", c.ToString(false));
|
||||
}
|
||||
LogPrintf(debugMsg);
|
||||
@ -545,7 +545,7 @@ void CDKGSessionHandler::HandleDKGRound()
|
||||
HandlePhase(QuorumPhase_Commit, QuorumPhase_Finalize, curQuorumHash, 0.5, fCommitStart, fCommitWait);
|
||||
|
||||
auto finalCommitments = curSession->FinalizeCommitments();
|
||||
for (auto& fqc : finalCommitments) {
|
||||
for (const auto& fqc : finalCommitments) {
|
||||
quorumBlockProcessor->AddMinableCommitment(fqc);
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
|
||||
std::vector<std::pair<NodeId, std::shared_ptr<Message>>> ret;
|
||||
ret.reserve(binaryMessages.size());
|
||||
for (auto& bm : binaryMessages) {
|
||||
for (const auto& bm : binaryMessages) {
|
||||
auto msg = std::make_shared<Message>();
|
||||
try {
|
||||
*bm.second >> *msg;
|
||||
@ -129,7 +129,7 @@ public:
|
||||
private:
|
||||
bool InitNewQuorum(int height, const uint256& quorumHash);
|
||||
|
||||
std::pair<QuorumPhase, uint256> GetPhaseAndQuorumHash();
|
||||
std::pair<QuorumPhase, uint256> GetPhaseAndQuorumHash() const;
|
||||
|
||||
typedef std::function<void()> StartPhaseFunc;
|
||||
typedef std::function<bool()> WhileWaitFunc;
|
||||
|
@ -25,7 +25,7 @@ CDKGSessionManager::CDKGSessionManager(CEvoDB& _evoDb, CBLSWorker& _blsWorker) :
|
||||
evoDb(_evoDb),
|
||||
blsWorker(_blsWorker)
|
||||
{
|
||||
for (auto& qt : Params().GetConsensus().llmqs) {
|
||||
for (const auto& qt : Params().GetConsensus().llmqs) {
|
||||
dkgSessionHandlers.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(qt.first),
|
||||
std::forward_as_tuple(qt.second, _evoDb, messageHandlerPool, blsWorker, *this));
|
||||
@ -104,7 +104,7 @@ bool CDKGSessionManager::AlreadyHave(const CInv& inv) const
|
||||
if (!sporkManager.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED))
|
||||
return false;
|
||||
|
||||
for (auto& p : dkgSessionHandlers) {
|
||||
for (const auto& p : dkgSessionHandlers) {
|
||||
auto& dkgType = p.second;
|
||||
if (dkgType.pendingContributions.HasSeen(inv.hash)
|
||||
|| dkgType.pendingComplaints.HasSeen(inv.hash)
|
||||
@ -121,7 +121,7 @@ bool CDKGSessionManager::GetContribution(const uint256& hash, CDKGContribution&
|
||||
if (!sporkManager.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED))
|
||||
return false;
|
||||
|
||||
for (auto& p : dkgSessionHandlers) {
|
||||
for (const auto& p : dkgSessionHandlers) {
|
||||
auto& dkgType = p.second;
|
||||
LOCK2(dkgType.cs, dkgType.curSession->invCs);
|
||||
if (dkgType.phase < QuorumPhase_Initialized || dkgType.phase > QuorumPhase_Contribute) {
|
||||
@ -141,7 +141,7 @@ bool CDKGSessionManager::GetComplaint(const uint256& hash, CDKGComplaint& ret) c
|
||||
if (!sporkManager.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED))
|
||||
return false;
|
||||
|
||||
for (auto& p : dkgSessionHandlers) {
|
||||
for (const auto& p : dkgSessionHandlers) {
|
||||
auto& dkgType = p.second;
|
||||
LOCK2(dkgType.cs, dkgType.curSession->invCs);
|
||||
if (dkgType.phase < QuorumPhase_Contribute || dkgType.phase > QuorumPhase_Complain) {
|
||||
@ -161,7 +161,7 @@ bool CDKGSessionManager::GetJustification(const uint256& hash, CDKGJustification
|
||||
if (!sporkManager.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED))
|
||||
return false;
|
||||
|
||||
for (auto& p : dkgSessionHandlers) {
|
||||
for (const auto& p : dkgSessionHandlers) {
|
||||
auto& dkgType = p.second;
|
||||
LOCK2(dkgType.cs, dkgType.curSession->invCs);
|
||||
if (dkgType.phase < QuorumPhase_Complain || dkgType.phase > QuorumPhase_Justify) {
|
||||
@ -181,7 +181,7 @@ bool CDKGSessionManager::GetPrematureCommitment(const uint256& hash, CDKGPrematu
|
||||
if (!sporkManager.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED))
|
||||
return false;
|
||||
|
||||
for (auto& p : dkgSessionHandlers) {
|
||||
for (const auto& p : dkgSessionHandlers) {
|
||||
auto& dkgType = p.second;
|
||||
LOCK2(dkgType.cs, dkgType.curSession->invCs);
|
||||
if (dkgType.phase < QuorumPhase_Justify || dkgType.phase > QuorumPhase_Commit) {
|
||||
|
@ -1969,8 +1969,8 @@ void CConnman::ThreadOpenMasternodeConnections()
|
||||
LOCK2(cs_vNodes, cs_vPendingMasternodes);
|
||||
|
||||
std::vector<CService> pending;
|
||||
for (auto& group : masternodeQuorumNodes) {
|
||||
for (auto& addr : group.second) {
|
||||
for (const auto& group : masternodeQuorumNodes) {
|
||||
for (const auto& addr : group.second) {
|
||||
if (!connectedNodes.count(addr) && !IsMasternodeOrDisconnectRequested(addr)) {
|
||||
pending.emplace_back(addr);
|
||||
}
|
||||
@ -2616,7 +2616,7 @@ std::set<uint256> CConnman::GetMasternodeQuorums(Consensus::LLMQType llmqType)
|
||||
{
|
||||
LOCK(cs_vPendingMasternodes);
|
||||
std::set<uint256> result;
|
||||
for (auto& p : masternodeQuorumNodes) {
|
||||
for (const auto& p : masternodeQuorumNodes) {
|
||||
if (p.first.first != llmqType) {
|
||||
continue;
|
||||
}
|
||||
@ -2643,7 +2643,7 @@ std::set<NodeId> CConnman::GetMasternodeQuorumNodes(Consensus::LLMQType llmqType
|
||||
return {};
|
||||
}
|
||||
std::set<NodeId> nodes;
|
||||
for (auto pnode : vNodes) {
|
||||
for (const auto pnode : vNodes) {
|
||||
if (pnode->fDisconnect) {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user