iterator cleanup in several places (#2164)

* iterator cleanup in Dash-specific code

* const

* *Pair/pair

* it++ -> ++it
This commit is contained in:
Nathan Marley 2018-07-12 16:07:51 +07:00 committed by UdjinM6
parent df1be90ce1
commit fd70a1eb92
8 changed files with 98 additions and 154 deletions

View File

@ -239,16 +239,12 @@ std::vector<CSuperblock_sptr> CGovernanceTriggerManager::GetActiveTriggers()
DBG( std::cout << "GetActiveTriggers: mapTrigger.size() = " << mapTrigger.size() << std::endl; );
// LOOK AT THESE OBJECTS AND COMPILE A VALID LIST OF TRIGGERS
trigger_m_it it = mapTrigger.begin();
while(it != mapTrigger.end()) {
CGovernanceObject* pObj = governance.FindGovernanceObject((*it).first);
for (const auto& pair : mapTrigger) {
CGovernanceObject* pObj = governance.FindGovernanceObject(pair.first);
if(pObj) {
DBG( std::cout << "GetActiveTriggers: pObj->GetDataAsPlainString() = " << pObj->GetDataAsPlainString() << std::endl; );
vecResults.push_back(it->second);
vecResults.push_back(pair.second);
}
++it;
}
DBG( std::cout << "GetActiveTriggers: vecResults.size() = " << vecResults.size() << std::endl; );

View File

@ -530,10 +530,10 @@ std::vector<CGovernanceVote> CGovernanceManager::GetCurrentVotes(const uint256&
vote_rec_t voteRecord;
if (!govobj.GetCurrentMNVotes(mnpair.first, voteRecord)) continue;
for (vote_instance_m_it it3 = voteRecord.mapInstances.begin(); it3 != voteRecord.mapInstances.end(); ++it3) {
int signal = (it3->first);
int outcome = ((it3->second).eOutcome);
int64_t nCreationTime = ((it3->second).nCreationTime);
for (const auto& voteInstancePair : voteRecord.mapInstances) {
int signal = voteInstancePair.first;
int outcome = voteInstancePair.second.eOutcome;
int64_t nCreationTime = voteInstancePair.second.nCreationTime;
CGovernanceVote vote = CGovernanceVote(mnpair.first, nParentHash, (vote_signal_enum_t)signal, (vote_outcome_enum_t)outcome);
vote.SetTime(nCreationTime);
@ -551,24 +551,15 @@ std::vector<const CGovernanceObject*> CGovernanceManager::GetAllNewerThan(int64_
std::vector<const CGovernanceObject*> vGovObjs;
object_m_cit it = mapObjects.begin();
while(it != mapObjects.end())
{
for (const auto& objPair : mapObjects) {
// IF THIS OBJECT IS OLDER THAN TIME, CONTINUE
if((*it).second.GetCreationTime() < nMoreThanTime) {
++it;
if(objPair.second.GetCreationTime() < nMoreThanTime) {
continue;
}
// ADD GOVERNANCE OBJECT TO LIST
const CGovernanceObject* pGovObj = &((*it).second);
const CGovernanceObject* pGovObj = &(objPair.second);
vGovObjs.push_back(pGovObj);
// NEXT
++it;
}
return vGovObjs;
@ -730,9 +721,10 @@ void CGovernanceManager::SyncAll(CNode* pnode, CConnman& connman) const
LOCK2(cs_main, cs);
// all valid objects, no votes
for(object_m_cit it = mapObjects.begin(); it != mapObjects.end(); ++it) {
const CGovernanceObject& govobj = it->second;
std::string strHash = it->first.ToString();
for (const auto& objPair : mapObjects) {
uint256 nHash = objPair.first;
const CGovernanceObject& govobj = objPair.second;
std::string strHash = nHash.ToString();
LogPrint("gobject", "CGovernanceManager::%s -- attempting to sync govobj: %s, peer=%d\n", __func__, strHash, pnode->id);
@ -744,7 +736,7 @@ void CGovernanceManager::SyncAll(CNode* pnode, CConnman& connman) const
// Push the inventory budget proposal message over to the other client
LogPrint("gobject", "CGovernanceManager::%s -- syncing govobj: %s, peer=%d\n", __func__, strHash, pnode->id);
pnode->PushInventory(CInv(MSG_GOVERNANCE_OBJECT, it->first));
pnode->PushInventory(CInv(MSG_GOVERNANCE_OBJECT, nHash));
++nObjCount;
}
@ -910,8 +902,8 @@ void CGovernanceManager::CheckMasternodeOrphanVotes(CConnman& connman)
ScopedLockBool guard(cs, fRateChecksEnabled, false);
for(object_m_it it = mapObjects.begin(); it != mapObjects.end(); ++it) {
it->second.CheckOrphanVotes(connman);
for (auto& objPair : mapObjects) {
objPair.second.CheckOrphanVotes(connman);
}
}
@ -1092,22 +1084,25 @@ int CGovernanceManager::RequestGovernanceObjectVotes(const std::vector<CNode*>&
if(mapObjects.empty()) return -2;
for(object_m_it it = mapObjects.begin(); it != mapObjects.end(); ++it) {
if(mapAskedRecently.count(it->first)) {
std::map<CService, int64_t>::iterator it1 = mapAskedRecently[it->first].begin();
while(it1 != mapAskedRecently[it->first].end()) {
if(it1->second < nNow) {
mapAskedRecently[it->first].erase(it1++);
for (const auto& objPair : mapObjects) {
uint256 nHash = objPair.first;
if(mapAskedRecently.count(nHash)) {
auto it = mapAskedRecently[nHash].begin();
while(it != mapAskedRecently[nHash].end()) {
if(it->second < nNow) {
mapAskedRecently[nHash].erase(it++);
} else {
++it1;
++it;
}
}
if(mapAskedRecently[it->first].size() >= nPeersPerHashMax) continue;
if(mapAskedRecently[nHash].size() >= nPeersPerHashMax) continue;
}
if(it->second.nObjectType == GOVERNANCE_OBJECT_TRIGGER) {
vpGovObjsTriggersTmp.push_back(&(it->second));
auto govObj = objPair.second;
if(govObj.nObjectType == GOVERNANCE_OBJECT_TRIGGER) {
vpGovObjsTriggersTmp.push_back(&govObj);
} else {
vpGovObjsTmp.push_back(&(it->second));
vpGovObjsTmp.push_back(&govObj);
}
}
}
@ -1194,8 +1189,8 @@ void CGovernanceManager::RebuildIndexes()
LOCK(cs);
cmapVoteToObject.Clear();
for(object_m_it it = mapObjects.begin(); it != mapObjects.end(); ++it) {
CGovernanceObject& govobj = it->second;
for (auto& objPair : mapObjects) {
CGovernanceObject& govobj = objPair.second;
std::vector<CGovernanceVote> vecVotes = govobj.GetVoteFile().GetVotes();
for(size_t i = 0; i < vecVotes.size(); ++i) {
cmapVoteToObject.Insert(vecVotes[i].GetHash(), &govobj);
@ -1242,10 +1237,8 @@ std::string CGovernanceManager::ToString() const
int nTriggerCount = 0;
int nOtherCount = 0;
object_m_cit it = mapObjects.begin();
while(it != mapObjects.end()) {
switch(it->second.GetObjectType()) {
for (const auto& objPair : mapObjects) {
switch(objPair.second.GetObjectType()) {
case GOVERNANCE_OBJECT_PROPOSAL:
nProposalCount++;
break;
@ -1256,7 +1249,6 @@ std::string CGovernanceManager::ToString() const
nOtherCount++;
break;
}
++it;
}
return strprintf("Governance Objects: %d (Proposals: %d, Triggers: %d, Other: %d; Erased: %d), Votes: %d",

View File

@ -223,12 +223,10 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
if(mapLockRequestAccepted.find(txHash) == mapLockRequestAccepted.end()) return;
// check if we need to vote on this candidate's outpoints,
// it's possible that we need to vote for several of them
std::map<COutPoint, COutPointLock>::iterator itOutpointLock = txLockCandidate.mapOutPointLocks.begin();
while(itOutpointLock != txLockCandidate.mapOutPointLocks.end()) {
int nPrevoutHeight = GetUTXOHeight(itOutpointLock->first);
for (auto& outpointLockPair : txLockCandidate.mapOutPointLocks) {
int nPrevoutHeight = GetUTXOHeight(outpointLockPair.first);
if(nPrevoutHeight == -1) {
LogPrint("instantsend", "CInstantSend::Vote -- Failed to find UTXO %s\n", itOutpointLock->first.ToStringShort());
LogPrint("instantsend", "CInstantSend::Vote -- Failed to find UTXO %s\n", outpointLockPair.first.ToStringShort());
return;
}
@ -238,20 +236,18 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
int nMinRequiredProtocol = std::max(MIN_INSTANTSEND_PROTO_VERSION, mnpayments.GetMinMasternodePaymentsProto());
if(!mnodeman.GetMasternodeRank(activeMasternode.outpoint, nRank, nLockInputHeight, nMinRequiredProtocol)) {
LogPrint("instantsend", "CInstantSend::Vote -- Can't calculate rank for masternode %s\n", activeMasternode.outpoint.ToStringShort());
++itOutpointLock;
continue;
}
int nSignaturesTotal = COutPointLock::SIGNATURES_TOTAL;
if(nRank > nSignaturesTotal) {
LogPrint("instantsend", "CInstantSend::Vote -- Masternode not in the top %d (%d)\n", nSignaturesTotal, nRank);
++itOutpointLock;
continue;
}
LogPrint("instantsend", "CInstantSend::Vote -- In the top %d (%d)\n", nSignaturesTotal, nRank);
std::map<COutPoint, std::set<uint256> >::iterator itVoted = mapVotedOutpoints.find(itOutpointLock->first);
std::map<COutPoint, std::set<uint256> >::iterator itVoted = mapVotedOutpoints.find(outpointLockPair.first);
// Check to see if we already voted for this outpoint,
// refuse to vote twice or to include the same outpoint in another tx
@ -259,23 +255,22 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
if(itVoted != mapVotedOutpoints.end()) {
for (const auto& hash : itVoted->second) {
std::map<uint256, CTxLockCandidate>::iterator it2 = mapTxLockCandidates.find(hash);
if(it2->second.HasMasternodeVoted(itOutpointLock->first, activeMasternode.outpoint)) {
if(it2->second.HasMasternodeVoted(outpointLockPair.first, activeMasternode.outpoint)) {
// we already voted for this outpoint to be included either in the same tx or in a competing one,
// skip it anyway
fAlreadyVoted = true;
LogPrintf("CInstantSend::Vote -- WARNING: We already voted for this outpoint, skipping: txHash=%s, outpoint=%s\n",
txHash.ToString(), itOutpointLock->first.ToStringShort());
txHash.ToString(), outpointLockPair.first.ToStringShort());
break;
}
}
}
if(fAlreadyVoted) {
++itOutpointLock;
continue; // skip to the next outpoint
}
// we haven't voted for this outpoint yet, let's try to do this now
CTxLockVote vote(txHash, itOutpointLock->first, activeMasternode.outpoint);
CTxLockVote vote(txHash, outpointLockPair.first, activeMasternode.outpoint);
if(!vote.Sign()) {
LogPrintf("CInstantSend::Vote -- Failed to sign consensus vote\n");
@ -289,27 +284,25 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
// vote constructed sucessfully, let's store and relay it
uint256 nVoteHash = vote.GetHash();
mapTxLockVotes.insert(std::make_pair(nVoteHash, vote));
if(itOutpointLock->second.AddVote(vote)) {
if(outpointLockPair.second.AddVote(vote)) {
LogPrintf("CInstantSend::Vote -- Vote created successfully, relaying: txHash=%s, outpoint=%s, vote=%s\n",
txHash.ToString(), itOutpointLock->first.ToStringShort(), nVoteHash.ToString());
txHash.ToString(), outpointLockPair.first.ToStringShort(), nVoteHash.ToString());
if(itVoted == mapVotedOutpoints.end()) {
std::set<uint256> setHashes;
setHashes.insert(txHash);
mapVotedOutpoints.insert(std::make_pair(itOutpointLock->first, setHashes));
mapVotedOutpoints.insert(std::make_pair(outpointLockPair.first, setHashes));
} else {
mapVotedOutpoints[itOutpointLock->first].insert(txHash);
if(mapVotedOutpoints[itOutpointLock->first].size() > 1) {
mapVotedOutpoints[outpointLockPair.first].insert(txHash);
if(mapVotedOutpoints[outpointLockPair.first].size() > 1) {
// it's ok to continue, just warn user
LogPrintf("CInstantSend::Vote -- WARNING: Vote conflicts with some existing votes: txHash=%s, outpoint=%s, vote=%s\n",
txHash.ToString(), itOutpointLock->first.ToStringShort(), nVoteHash.ToString());
txHash.ToString(), outpointLockPair.first.ToStringShort(), nVoteHash.ToString());
}
}
vote.Relay(connman);
}
++itOutpointLock;
}
}
@ -548,11 +541,8 @@ void CInstantSend::LockTransactionInputs(const CTxLockCandidate& txLockCandidate
if(!txLockCandidate.IsAllOutPointsReady()) return;
std::map<COutPoint, COutPointLock>::const_iterator it = txLockCandidate.mapOutPointLocks.begin();
while(it != txLockCandidate.mapOutPointLocks.end()) {
mapLockedOutpoints.insert(std::make_pair(it->first, txHash));
++it;
for (const auto& pair : txLockCandidate.mapOutPointLocks) {
mapLockedOutpoints.insert(std::make_pair(pair.first, txHash));
}
LogPrint("instantsend", "CInstantSend::LockTransactionInputs -- done, txid=%s\n", txHash.ToString());
}
@ -648,12 +638,9 @@ int64_t CInstantSend::GetAverageMasternodeOrphanVoteTime()
// NOTE: should never actually call this function when mapMasternodeOrphanVotes is empty
if(mapMasternodeOrphanVotes.empty()) return 0;
std::map<COutPoint, int64_t>::iterator it = mapMasternodeOrphanVotes.begin();
int64_t total = 0;
while(it != mapMasternodeOrphanVotes.end()) {
total+= it->second;
++it;
for (const auto& pair : mapMasternodeOrphanVotes) {
total += pair.second;
}
return total / mapMasternodeOrphanVotes.size();
@ -673,11 +660,10 @@ void CInstantSend::CheckAndRemove()
uint256 txHash = txLockCandidate.GetHash();
if(txLockCandidate.IsExpired(nCachedBlockHeight)) {
LogPrintf("CInstantSend::CheckAndRemove -- Removing expired Transaction Lock Candidate: txid=%s\n", txHash.ToString());
std::map<COutPoint, COutPointLock>::iterator itOutpointLock = txLockCandidate.mapOutPointLocks.begin();
while(itOutpointLock != txLockCandidate.mapOutPointLocks.end()) {
mapLockedOutpoints.erase(itOutpointLock->first);
mapVotedOutpoints.erase(itOutpointLock->first);
++itOutpointLock;
for (const auto& pair : txLockCandidate.mapOutPointLocks) {
mapLockedOutpoints.erase(pair.first);
mapVotedOutpoints.erase(pair.first);
}
mapLockRequestAccepted.erase(txHash);
mapLockRequestRejected.erase(txHash);
@ -828,11 +814,9 @@ bool CInstantSend::IsLockedInstantSendTransaction(const uint256& txHash)
if(itLockCandidate->second.mapOutPointLocks.empty()) return false;
// and all of these outputs must be included in mapLockedOutpoints with correct hash
std::map<COutPoint, COutPointLock>::iterator itOutpointLock = itLockCandidate->second.mapOutPointLocks.begin();
while(itOutpointLock != itLockCandidate->second.mapOutPointLocks.end()) {
for (const auto& pair : itLockCandidate->second.mapOutPointLocks) {
uint256 hashLocked;
if(!GetLockedOutPointTxHash(itOutpointLock->first, hashLocked) || hashLocked != txHash) return false;
++itOutpointLock;
if(!GetLockedOutPointTxHash(pair.first, hashLocked) || hashLocked != txHash) return false;
}
return true;
@ -912,35 +896,28 @@ void CInstantSend::SyncTransaction(const CTransaction& tx, const CBlockIndex *pi
txHash.ToString(), nHeightNew);
itLockCandidate->second.SetConfirmedHeight(nHeightNew);
// Loop through outpoint locks
std::map<COutPoint, COutPointLock>::iterator itOutpointLock = itLockCandidate->second.mapOutPointLocks.begin();
while(itOutpointLock != itLockCandidate->second.mapOutPointLocks.end()) {
for (const auto& pair : itLockCandidate->second.mapOutPointLocks) {
// Check corresponding lock votes
std::vector<CTxLockVote> vVotes = itOutpointLock->second.GetVotes();
std::vector<CTxLockVote>::iterator itVote = vVotes.begin();
std::map<uint256, CTxLockVote>::iterator it;
while(itVote != vVotes.end()) {
uint256 nVoteHash = itVote->GetHash();
for (const auto& vote : pair.second.GetVotes()) {
uint256 nVoteHash = vote.GetHash();
LogPrint("instantsend", "CInstantSend::SyncTransaction -- txid=%s nHeightNew=%d vote %s updated\n",
txHash.ToString(), nHeightNew, nVoteHash.ToString());
it = mapTxLockVotes.find(nVoteHash);
const auto& it = mapTxLockVotes.find(nVoteHash);
if(it != mapTxLockVotes.end()) {
it->second.SetConfirmedHeight(nHeightNew);
}
++itVote;
}
++itOutpointLock;
}
}
// check orphan votes
std::map<uint256, CTxLockVote>::iterator itOrphanVote = mapTxLockVotesOrphan.begin();
while(itOrphanVote != mapTxLockVotesOrphan.end()) {
if(itOrphanVote->second.GetTxHash() == txHash) {
for (const auto& pair : mapTxLockVotesOrphan) {
if(pair.second.GetTxHash() == txHash) {
LogPrint("instantsend", "CInstantSend::SyncTransaction -- txid=%s nHeightNew=%d vote %s updated\n",
txHash.ToString(), nHeightNew, itOrphanVote->first.ToString());
mapTxLockVotes[itOrphanVote->first].SetConfirmedHeight(nHeightNew);
txHash.ToString(), nHeightNew, pair.first.ToString());
mapTxLockVotes[pair.first].SetConfirmedHeight(nHeightNew);
}
++itOrphanVote;
}
}
@ -1178,10 +1155,8 @@ bool COutPointLock::AddVote(const CTxLockVote& vote)
std::vector<CTxLockVote> COutPointLock::GetVotes() const
{
std::vector<CTxLockVote> vRet;
std::map<COutPoint, CTxLockVote>::const_iterator itVote = mapMasternodeVotes.begin();
while(itVote != mapMasternodeVotes.end()) {
vRet.push_back(itVote->second);
++itVote;
for (const auto& pair : mapMasternodeVotes) {
vRet.push_back(pair.second);
}
return vRet;
}
@ -1193,10 +1168,8 @@ bool COutPointLock::HasMasternodeVoted(const COutPoint& outpointMasternodeIn) co
void COutPointLock::Relay(CConnman& connman) const
{
std::map<COutPoint, CTxLockVote>::const_iterator itVote = mapMasternodeVotes.begin();
while(itVote != mapMasternodeVotes.end()) {
itVote->second.Relay(connman);
++itVote;
for (const auto& pair : mapMasternodeVotes) {
pair.second.Relay(connman);
}
}
@ -1227,10 +1200,8 @@ bool CTxLockCandidate::IsAllOutPointsReady() const
{
if(mapOutPointLocks.empty()) return false;
std::map<COutPoint, COutPointLock>::const_iterator it = mapOutPointLocks.begin();
while(it != mapOutPointLocks.end()) {
if(!it->second.IsReady()) return false;
++it;
for (const auto& pair : mapOutPointLocks) {
if(!pair.second.IsReady()) return false;
}
return true;
}
@ -1245,10 +1216,8 @@ int CTxLockCandidate::CountVotes() const
{
// Note: do NOT use vote count to figure out if tx is locked, use IsAllOutPointsReady() instead
int nCountVotes = 0;
std::map<COutPoint, COutPointLock>::const_iterator it = mapOutPointLocks.begin();
while(it != mapOutPointLocks.end()) {
nCountVotes += it->second.CountVotes();
++it;
for (const auto& pair : mapOutPointLocks) {
nCountVotes += pair.second.CountVotes();
}
return nCountVotes;
}
@ -1267,9 +1236,7 @@ bool CTxLockCandidate::IsTimedOut() const
void CTxLockCandidate::Relay(CConnman& connman) const
{
connman.RelayTransaction(*txLockRequest.tx);
std::map<COutPoint, COutPointLock>::const_iterator itOutpointLock = mapOutPointLocks.begin();
while(itOutpointLock != mapOutPointLocks.end()) {
itOutpointLock->second.Relay(connman);
++itOutpointLock;
for (const auto& pair : mapOutPointLocks) {
pair.second.Relay(connman);
}
}

View File

@ -1009,12 +1009,11 @@ void CMasternodePayments::RequestLowDataPaymentBlocks(CNode* pnode, CConnman& co
pindex = pindex->pprev;
}
auto it = mapMasternodeBlocks.begin();
while(it != mapMasternodeBlocks.end()) {
for (auto& mnBlockPayees : mapMasternodeBlocks) {
int nBlockHeight = mnBlockPayees.first;
int nTotalVotes = 0;
bool fFound = false;
for (const auto& payee : it->second.vecPayees) {
for (const auto& payee : mnBlockPayees.second.vecPayees) {
if(payee.GetVoteCount() >= MNPAYMENTS_SIGNATURES_REQUIRED) {
fFound = true;
break;
@ -1025,24 +1024,23 @@ void CMasternodePayments::RequestLowDataPaymentBlocks(CNode* pnode, CConnman& co
// or no clear winner was found but there are at least avg number of votes
if(fFound || nTotalVotes >= (MNPAYMENTS_SIGNATURES_TOTAL + MNPAYMENTS_SIGNATURES_REQUIRED)/2) {
// so just move to the next block
++it;
continue;
}
// DEBUG
DBG (
// Let's see why this failed
for (const auto& payee : it->second.vecPayees) {
for (const auto& payee : mnBlockPayees.second.vecPayees) {
CTxDestination address1;
ExtractDestination(payee.GetPayee(), address1);
CBitcoinAddress address2(address1);
printf("payee %s votes %d\n", address2.ToString().c_str(), payee.GetVoteCount());
}
printf("block %d votes total %d\n", it->first, nTotalVotes);
printf("block %d votes total %d\n", nBlockHeight, nTotalVotes);
)
// END DEBUG
// Low data block found, let's try to sync it
uint256 hash;
if(GetBlockHash(hash, it->first)) {
if(GetBlockHash(hash, nBlockHeight)) {
vToFetch.push_back(CInv(MSG_MASTERNODE_PAYMENT_BLOCK, hash));
}
// We should not violate GETDATA rules
@ -1052,7 +1050,6 @@ void CMasternodePayments::RequestLowDataPaymentBlocks(CNode* pnode, CConnman& co
// Start filling new batch
vToFetch.clear();
}
++it;
}
// Ask for the rest of it
if(!vToFetch.empty()) {

View File

@ -772,14 +772,11 @@ void CMasternodeMan::ProcessPendingMnbRequests(CConnman& connman)
bool fDone = connman.ForNode(itPendingMNB->first, [&](CNode* pnode) {
// compile request vector
std::vector<CInv> vToFetch;
std::set<uint256>& setHashes = itPendingMNB->second.second;
std::set<uint256>::iterator it = setHashes.begin();
while(it != setHashes.end()) {
if(*it != uint256()) {
vToFetch.push_back(CInv(MSG_MASTERNODE_ANNOUNCE, *it));
LogPrint("masternode", "-- asking for mnb %s from addr=%s\n", it->ToString(), pnode->addr.ToString());
for (auto& nHash : itPendingMNB->second.second) {
if(nHash != uint256()) {
vToFetch.push_back(CInv(MSG_MASTERNODE_ANNOUNCE, nHash));
LogPrint("masternode", "-- asking for mnb %s from addr=%s\n", nHash.ToString(), pnode->addr.ToString());
}
++it;
}
// ask for data
@ -1013,20 +1010,18 @@ void CMasternodeMan::DoFullVerificationStep(CConnman& connman)
int nRanksTotal = (int)vecMasternodeRanks.size();
// send verify requests only if we are in top MAX_POSE_RANK
rank_pair_vec_t::iterator it = vecMasternodeRanks.begin();
while(it != vecMasternodeRanks.end()) {
if(it->first > MAX_POSE_RANK) {
for (auto& rankPair : vecMasternodeRanks) {
if(rankPair.first > MAX_POSE_RANK) {
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Must be in top %d to send verify request\n",
(int)MAX_POSE_RANK);
return;
}
if(it->second.outpoint == activeMasternode.outpoint) {
nMyRank = it->first;
if(rankPair.second.outpoint == activeMasternode.outpoint) {
nMyRank = rankPair.first;
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Found self at rank %d/%d, verifying up to %d masternodes\n",
nMyRank, nRanksTotal, (int)MAX_POSE_CONNECTIONS);
break;
}
++it;
}
// edge case: list is too short and this masternode is not enabled
@ -1044,7 +1039,7 @@ void CMasternodeMan::DoFullVerificationStep(CConnman& connman)
sort(vSortedByAddr.begin(), vSortedByAddr.end(), CompareByAddr());
it = vecMasternodeRanks.begin() + nOffset;
auto it = vecMasternodeRanks.begin() + nOffset;
while(it != vecMasternodeRanks.end()) {
if(it->second.IsPoSeVerified() || it->second.IsPoSeBanned()) {
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Already %s%s%s masternode %s address %s, skipping...\n",

View File

@ -1342,7 +1342,8 @@ bool CPrivateSendClient::CreateDenominated(const CompactTallyItem& tallyItem, bo
do {
std::vector<CAmount> vecStandardDenoms = CPrivateSend::GetStandardDenominations();
BOOST_REVERSE_FOREACH(CAmount nDenomValue, vecStandardDenoms) {
for (auto it = vecStandardDenoms.rbegin(); it != vecStandardDenoms.rend(); ++it) {
CAmount nDenomValue = *it;
if(fSkip) {
// Note: denoms are skipped if there are already DENOMS_COUNT_MAX of them

View File

@ -417,8 +417,8 @@ int CPrivateSend::GetDenominationsByAmounts(const std::vector<CAmount>& vecAmoun
CScript scriptTmp = CScript();
std::vector<CTxOut> vecTxOut;
BOOST_REVERSE_FOREACH(CAmount nAmount, vecAmount) {
CTxOut txout(nAmount, scriptTmp);
for (auto it = vecAmount.rbegin(); it != vecAmount.rend(); ++it) {
CTxOut txout((*it), scriptTmp);
vecTxOut.push_back(txout);
}

View File

@ -73,12 +73,8 @@ void CSporkManager::ProcessSpork(CNode* pfrom, const std::string& strCommand, CD
ExecuteSpork(spork.nSporkID, spork.nValue);
} else if (strCommand == NetMsgType::GETSPORKS) {
std::map<int, CSporkMessage>::iterator it = mapSporksActive.begin();
while(it != mapSporksActive.end()) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::SPORK, it->second));
it++;
for (const auto& pair : mapSporksActive) {
connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::SPORK, pair.second));
}
}