Skip to content

Commit

Permalink
Add some consts
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 authored and codablock committed Jan 11, 2019
1 parent 0b1347c commit 8b7771a
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
36 changes: 18 additions & 18 deletions src/llmq/quorums_dkgsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
Expand Down Expand Up @@ -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__);

Expand Down Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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__);

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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__);

Expand Down Expand Up @@ -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++;
}
Expand All @@ -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;
Expand All @@ -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());
}
}
Expand Down Expand Up @@ -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__);

Expand Down Expand Up @@ -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++;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions src/llmq/quorums_dkgsession.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down Expand Up @@ -310,26 +310,26 @@ class CDKGSession
// 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
Expand All @@ -339,10 +339,10 @@ class CDKGSession
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;
};

}
Expand Down
6 changes: 3 additions & 3 deletions src/llmq/quorums_dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/llmq/quorums_dkgsessionhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CDKGPendingMessages

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;
Expand Down Expand Up @@ -129,7 +129,7 @@ class CDKGSessionHandler
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;
Expand Down
12 changes: 6 additions & 6 deletions src/llmq/quorums_dkgsessionmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 8b7771a

Please sign in to comment.