From 4d44c9781a95bb80e81f48e551e791a1eeb8cb66 Mon Sep 17 00:00:00 2001 From: warrows Date: Wed, 6 Mar 2019 20:05:20 +0100 Subject: [PATCH] [Refactoring] Replace BOOST FOREACH with for : Done using following script: -BEGIN VERIFY SCRIPT- sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; -END VERIFY SCRIPT- --- src/activemasternode.cpp | 12 +- src/alert.cpp | 4 +- src/bloom.cpp | 2 +- src/checkqueue.h | 4 +- src/coins.h | 4 +- src/core_write.cpp | 2 +- src/crypter.cpp | 2 +- src/init.cpp | 20 ++-- src/kernel.cpp | 4 +- src/main.cpp | 93 ++++++++-------- src/masternode-budget.cpp | 12 +- src/masternode-payments.cpp | 8 +- src/masternode-payments.h | 6 +- src/masternode-sync.cpp | 4 +- src/masternodeman.cpp | 46 ++++---- src/miner.cpp | 2 +- src/net.cpp | 68 ++++++------ src/net.h | 6 +- src/obfuscation.cpp | 112 +++++++++---------- src/obfuscation.h | 6 +- src/pivx-tx.cpp | 2 +- src/qt/addresstablemodel.cpp | 2 +- src/qt/blockexplorer.cpp | 2 +- src/qt/clientmodel.cpp | 2 +- src/qt/coincontroldialog.cpp | 4 +- src/qt/masternodelist.cpp | 6 +- src/qt/peertablemodel.cpp | 2 +- src/qt/recentrequeststablemodel.cpp | 2 +- src/qt/transactiondesc.cpp | 18 +-- src/qt/transactionrecord.cpp | 6 +- src/qt/walletmodel.cpp | 12 +- src/rest.cpp | 6 +- src/rpc/blockchain.cpp | 16 +-- src/rpc/budget.cpp | 12 +- src/rpc/masternode.cpp | 18 +-- src/rpc/mining.cpp | 4 +- src/rpc/misc.cpp | 2 +- src/rpc/net.cpp | 22 ++-- src/rpc/rawtransaction.cpp | 10 +- src/rpc/server.cpp | 6 +- src/script/sign.cpp | 8 +- src/script/standard.cpp | 4 +- src/swifttx.cpp | 20 ++-- src/test/accounting_tests.cpp | 2 +- src/test/alert_tests.cpp | 4 +- src/test/bip32_tests.cpp | 2 +- src/test/getarg_tests.cpp | 2 +- src/test/miner_tests.cpp | 2 +- src/test/multisig_tests.cpp | 2 +- src/test/script_tests.cpp | 6 +- src/test/transaction_tests.cpp | 2 +- src/test/zerocoin_implementation_tests.cpp | 2 +- src/timedata.cpp | 4 +- src/torcontrol.cpp | 6 +- src/txmempool.cpp | 28 ++--- src/wallet/rpcdump.cpp | 2 +- src/wallet/rpcwallet.cpp | 46 ++++---- src/wallet/test/wallet_tests.cpp | 2 +- src/wallet/wallet.cpp | 122 ++++++++++----------- src/wallet/wallet.h | 12 +- src/wallet/wallet_ismine.cpp | 2 +- src/wallet/walletdb.cpp | 14 +-- 62 files changed, 433 insertions(+), 432 deletions(-) diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp index 93f5926d7e412..f5180fc5ea9ff 100644 --- a/src/activemasternode.cpp +++ b/src/activemasternode.cpp @@ -218,7 +218,7 @@ bool CActiveMasternode::SendMasternodePing(std::string& errorMessage) LogPrint("masternode", "dseep - relaying from active mn, %s \n", vin.ToString().c_str()); LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) pnode->PushMessage("dseep", vin, vchMasterNodeSignature, masterNodeSignatureTime, false); /* @@ -326,7 +326,7 @@ bool CActiveMasternode::CreateBroadcast(CTxIn vin, CService service, CKey keyCol } LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) pnode->PushMessage("dsee", vin, service, vchMasterNodeSignature, masterNodeSignatureTime, pubKeyCollateralAddress, pubKeyMasternode, -1, -1, masterNodeSignatureTime, PROTOCOL_VERSION, donationAddress, donationPercantage); /* @@ -366,7 +366,7 @@ bool CActiveMasternode::GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secr } bool found = false; - BOOST_FOREACH (COutput& out, possibleCoins) { + for (COutput& out : possibleCoins) { if (out.tx->GetHash() == txHash && out.i == outputIndex) { selectedOutput = &out; found = true; @@ -432,7 +432,7 @@ vector CActiveMasternode::SelectCoinsMasternode() // Temporary unlock MN coins from masternode.conf if (GetBoolArg("-mnconflock", true)) { uint256 mnTxHash; - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { mnTxHash.SetHex(mne.getTxHash()); int nIndex; @@ -450,12 +450,12 @@ vector CActiveMasternode::SelectCoinsMasternode() // Lock MN coins from masternode.conf back if they where temporary unlocked if (!confLockedCoins.empty()) { - BOOST_FOREACH (COutPoint outpoint, confLockedCoins) + for (COutPoint outpoint : confLockedCoins) pwalletMain->LockCoin(outpoint); } // Filter - BOOST_FOREACH (const COutput& out, vCoins) { + for (const COutput& out : vCoins) { if (out.tx->vout[out.i].nValue == 10000 * COIN) { //exactly filteredCoins.push_back(out); } diff --git a/src/alert.cpp b/src/alert.cpp index 14afa65a7a8c8..32cf1abb4c3f8 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -52,7 +52,7 @@ std::string CUnsignedAlert::ToString() const for (auto& n: setCancel) strSetCancel += strprintf("%d ", n); std::string strSetSubVer; - BOOST_FOREACH (std::string str, setSubVer) + for (std::string str : setSubVer) strSetSubVer += "\"" + str + "\" "; return strprintf( "CAlert(\n" @@ -213,7 +213,7 @@ bool CAlert::ProcessAlert(bool fThread) } // Check if this alert has been cancelled - BOOST_FOREACH (PAIRTYPE(const uint256, CAlert) & item, mapAlerts) { + for (PAIRTYPE(const uint256, CAlert) & item : mapAlerts) { const CAlert& alert = item.second; if (alert.Cancels(*this)) { LogPrint("alert", "alert already cancelled by %d\n", alert.nID); diff --git a/src/bloom.cpp b/src/bloom.cpp index 7e9eb0d12b7b5..cb482637c31ad 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -207,7 +207,7 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx) if (fFound) return true; - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { // Match if the filter contains an outpoint tx spends if (contains(txin.prevout)) return true; diff --git a/src/checkqueue.h b/src/checkqueue.h index 9648347c6653a..a66f0b37c0914 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -119,7 +119,7 @@ class CCheckQueue fOk = fAllOk; } // execute work - BOOST_FOREACH (T& check, vChecks) + for (T& check : vChecks) if (fOk) fOk = check(); vChecks.clear(); @@ -146,7 +146,7 @@ class CCheckQueue void Add(std::vector& vChecks) { boost::unique_lock lock(mutex); - BOOST_FOREACH (T& check, vChecks) { + for (T& check : vChecks) { queue.push_back(T()); check.swap(queue.back()); } diff --git a/src/coins.h b/src/coins.h index 8619ce672102d..d8c06fd4a2363 100644 --- a/src/coins.h +++ b/src/coins.h @@ -128,7 +128,7 @@ class CCoins void ClearUnspendable() { - BOOST_FOREACH (CTxOut& txout, vout) { + for (CTxOut& txout : vout) { if (txout.scriptPubKey.IsUnspendable()) txout.SetNull(); } @@ -279,7 +279,7 @@ class CCoins //! note that only !IsPruned() CCoins can be serialized bool IsPruned() const { - BOOST_FOREACH (const CTxOut& out, vout) + for (const CTxOut& out : vout) if (!out.IsNull()) return false; return true; diff --git a/src/core_write.cpp b/src/core_write.cpp index 39c4dd4542662..320a66d1179c1 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -83,7 +83,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey, out.pushKV("type", GetTxnOutputType(type)); UniValue a(UniValue::VARR); - BOOST_FOREACH (const CTxDestination& addr, addresses) + for (const CTxDestination& addr : addresses) a.push_back(CBitcoinAddress(addr).ToString()); out.pushKV("addresses", a); } diff --git a/src/crypter.cpp b/src/crypter.cpp index 97ce042bf0767..f19e018b26ed8 100644 --- a/src/crypter.cpp +++ b/src/crypter.cpp @@ -358,7 +358,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) return false; fUseCrypto = true; - BOOST_FOREACH (KeyMap::value_type& mKey, mapKeys) { + for (KeyMap::value_type& mKey : mapKeys) { const CKey& key = mKey.second; CPubKey vchPubKey = key.GetPubKey(); CKeyingMaterial vchSecret(key.begin(), key.end()); diff --git a/src/init.cpp b/src/init.cpp index 217e3032280b7..d3bb0dfcb6977 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -695,7 +695,7 @@ void ThreadImport(std::vector vImportFiles) } // -loadblock= - BOOST_FOREACH (boost::filesystem::path& path, vImportFiles) { + for (boost::filesystem::path& path : vImportFiles) { FILE* file = fopen(path.string().c_str(), "rb"); if (file) { CImportingNow imp; @@ -1264,7 +1264,7 @@ bool AppInit2() if (mapArgs.count("-onlynet")) { std::set nets; - BOOST_FOREACH (std::string snet, mapMultiArgs["-onlynet"]) { + for (std::string snet : mapMultiArgs["-onlynet"]) { enum Network net = ParseNetwork(snet); if (net == NET_UNROUTABLE) return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet)); @@ -1278,7 +1278,7 @@ bool AppInit2() } if (mapArgs.count("-whitelist")) { - BOOST_FOREACH (const std::string& net, mapMultiArgs["-whitelist"]) { + for (const std::string& net : mapMultiArgs["-whitelist"]) { CSubNet subnet(net); if (!subnet.IsValid()) return InitError(strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net)); @@ -1338,13 +1338,13 @@ bool AppInit2() bool fBound = false; if (fListen) { if (mapArgs.count("-bind") || mapArgs.count("-whitebind")) { - BOOST_FOREACH (std::string strBind, mapMultiArgs["-bind"]) { + for (std::string strBind : mapMultiArgs["-bind"]) { CService addrBind; if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind)); fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR)); } - BOOST_FOREACH (std::string strBind, mapMultiArgs["-whitebind"]) { + for (std::string strBind : mapMultiArgs["-whitebind"]) { CService addrBind; if (!Lookup(strBind.c_str(), addrBind, 0, false)) return InitError(strprintf(_("Cannot resolve -whitebind address: '%s'"), strBind)); @@ -1363,7 +1363,7 @@ bool AppInit2() } if (mapArgs.count("-externalip")) { - BOOST_FOREACH (string strAddr, mapMultiArgs["-externalip"]) { + for (string strAddr : mapMultiArgs["-externalip"]) { CService addrLocal(strAddr, GetListenPort(), fNameLookup); if (!addrLocal.IsValid()) return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr)); @@ -1371,7 +1371,7 @@ bool AppInit2() } } - BOOST_FOREACH (string strDest, mapMultiArgs["-seednode"]) + for (string strDest : mapMultiArgs["-seednode"]) AddOneShot(strDest); #if ENABLE_ZMQ @@ -1745,7 +1745,7 @@ bool AppInit2() // Restore wallet transaction metadata after -zapwallettxes=1 if (GetBoolArg("-zapwallettxes", false) && GetArg("-zapwallettxes", "1") != "2") { - BOOST_FOREACH (const CWalletTx& wtxOld, vWtx) { + for (const CWalletTx& wtxOld : vWtx) { uint256 hash = wtxOld.GetHash(); std::map::iterator mi = pwalletMain->mapWallet.find(hash); if (mi != pwalletMain->mapWallet.end()) { @@ -1796,7 +1796,7 @@ bool AppInit2() std::vector vImportFiles; if (mapArgs.count("-loadblock")) { - BOOST_FOREACH (string strFile, mapMultiArgs["-loadblock"]) + for (string strFile : mapMultiArgs["-loadblock"]) vImportFiles.push_back(strFile); } threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles)); @@ -1902,7 +1902,7 @@ bool AppInit2() LOCK(pwalletMain->cs_wallet); LogPrintf("Locking Masternodes:\n"); uint256 mnTxHash; - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { LogPrintf(" %s %s\n", mne.getTxHash(), mne.getOutputIndex()); mnTxHash.SetHex(mne.getTxHash()); COutPoint outpoint = COutPoint(mnTxHash, (unsigned int) std::stoul(mne.getOutputIndex().c_str())); diff --git a/src/kernel.cpp b/src/kernel.cpp index 3f0dfac78e914..3773ffaf2609a 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -87,7 +87,7 @@ static bool SelectBlockFromCandidates( bool fSelected = false; uint256 hashBest = 0; *pindexSelected = (const CBlockIndex*)0; - BOOST_FOREACH (const PAIRTYPE(int64_t, uint256) & item, vSortedByTimestamp) { + for (const PAIRTYPE(int64_t, uint256) & item : vSortedByTimestamp) { if (!mapBlockIndex.count(item.second)) return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString().c_str()); @@ -225,7 +225,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeMod strSelectionMap.replace(pindex->nHeight - nHeightFirstCandidate, 1, "="); pindex = pindex->pprev; } - BOOST_FOREACH (const PAIRTYPE(uint256, const CBlockIndex*) & item, mapSelectedBlocks) { + for (const PAIRTYPE(uint256, const CBlockIndex*) & item : mapSelectedBlocks) { // 'S' indicates selected proof-of-stake blocks // 'W' indicates selected proof-of-work blocks strSelectionMap.replace(item.second->nHeight - nHeightFirstCandidate, 1, item.second->IsProofOfStake() ? "S" : "W"); diff --git a/src/main.cpp b/src/main.cpp index 47331c9484b84..1e41d2b99121e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -384,7 +384,7 @@ void FinalizeNode(NodeId nodeid) AddressCurrentlyConnected(state->address); } - BOOST_FOREACH (const QueuedBlock& entry, state->vBlocksInFlight) + for (const QueuedBlock& entry : state->vBlocksInFlight) mapBlocksInFlight.erase(entry.hash); EraseOrphansFor(nodeid); nPreferredDownload -= state->fPreferredDownload; @@ -531,7 +531,7 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vectorIsValid(BLOCK_VALID_TREE)) { // We consider the chain that this peer is on invalid. return; @@ -572,7 +572,7 @@ bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) stats.nMisbehavior = state->nMisbehavior; stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1; stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1; - BOOST_FOREACH (const QueuedBlock& queue, state->vBlocksInFlight) { + for (const QueuedBlock& queue : state->vBlocksInFlight) { if (queue.pindex) stats.vHeightInFlight.push_back(queue.pindex->nHeight); } @@ -600,7 +600,7 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals) CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) { // Find the first block the caller has in the main chain - BOOST_FOREACH (const uint256& hash, locator.vHave) { + for (const uint256& hash : locator.vHave) { BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; @@ -642,7 +642,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) mapOrphanTransactions[hash].tx = tx; mapOrphanTransactions[hash].fromPeer = peer; - BOOST_FOREACH (const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash); LogPrint("mempool", "stored orphan tx %s (mapsz %u prevsz %u)\n", hash.ToString(), @@ -655,7 +655,7 @@ void static EraseOrphanTx(uint256 hash) map::iterator it = mapOrphanTransactions.find(hash); if (it == mapOrphanTransactions.end()) return; - BOOST_FOREACH (const CTxIn& txin, it->second.tx.vin) { + for (const CTxIn& txin : it->second.tx.vin) { map >::iterator itPrev = mapOrphanTransactionsByPrev.find(txin.prevout.hash); if (itPrev == mapOrphanTransactionsByPrev.end()) continue; @@ -759,7 +759,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) unsigned int nDataOut = 0; txnouttype whichType; - BOOST_FOREACH (const CTxOut& txout, tx.vout) { + for (const CTxOut& txout : tx.vout) { if (!::IsStandard(txout.scriptPubKey, whichType)) { reason = "scriptpubkey"; return false; @@ -797,7 +797,7 @@ bool IsFinalTx(const CTransaction& tx, int nBlockHeight, int64_t nBlockTime) nBlockTime = GetAdjustedTime(); if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) return true; - BOOST_FOREACH (const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) if (!txin.IsFinal()) return false; return true; @@ -870,10 +870,10 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) unsigned int GetLegacySigOpCount(const CTransaction& tx) { unsigned int nSigOps = 0; - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { nSigOps += txin.scriptSig.GetSigOpCount(false); } - BOOST_FOREACH (const CTxOut& txout, tx.vout) { + for (const CTxOut& txout : tx.vout) { nSigOps += txout.scriptPubKey.GetSigOpCount(false); } return nSigOps; @@ -1141,7 +1141,7 @@ bool CheckTransaction(const CTransaction& tx, bool fZerocoinActive, bool fReject // Check for negative or overflow output values CAmount nValueOut = 0; - BOOST_FOREACH (const CTxOut& txout, tx.vout) { + for (const CTxOut& txout : tx.vout) { if (txout.IsEmpty() && !tx.IsCoinBase() && !tx.IsCoinStake()) return state.DoS(100, error("CheckTransaction(): txout empty for user transaction")); @@ -1204,7 +1204,7 @@ bool CheckTransaction(const CTransaction& tx, bool fZerocoinActive, bool fReject if(tx.vin.size() < 1 || static_cast(tx.vin.size()) > Params().Zerocoin_MaxSpendsPerTransaction()) return state.DoS(10, error("CheckTransaction() : Zerocoin Spend has more than allowed txin's"), REJECT_INVALID, "bad-zerocoinspend"); } else { - BOOST_FOREACH (const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) if (txin.prevout.IsNull() && (fZerocoinActive && !txin.IsZerocoinSpend())) return state.DoS(10, error("CheckTransaction() : prevout is null"), REJECT_INVALID, "bad-txns-prevout-null"); @@ -1317,7 +1317,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa // ----------- swiftTX transaction scanning ----------- - BOOST_FOREACH (const CTxIn& in, tx.vin) { + for (const CTxIn& in : tx.vin) { if (mapLockedInputs.count(in.prevout)) { if (mapLockedInputs[in.prevout] != tx.GetHash()) { return state.DoS(0, @@ -1564,7 +1564,7 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact // ----------- swiftTX transaction scanning ----------- - BOOST_FOREACH (const CTxIn& in, tx.vin) { + for (const CTxIn& in : tx.vin) { if (mapLockedInputs.count(in.prevout)) { if (mapLockedInputs[in.prevout] != tx.GetHash()) { return state.DoS(0, @@ -1789,7 +1789,7 @@ bool GetTransaction(const uint256& hash, CTransaction& txOut, uint256& hashBlock if (pindexSlow) { CBlock block; if (ReadBlockFromDisk(block, pindexSlow)) { - BOOST_FOREACH (const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { if (tx.GetHash() == hash) { txOut = tx; hashBlock = pindexSlow->GetBlockHash(); @@ -2344,7 +2344,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState& state, CCoinsViewCach // mark inputs spent if (!tx.IsCoinBase() && !tx.HasZerocoinSpendInputs()) { txundo.vprevout.reserve(tx.vin.size()); - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { txundo.vprevout.push_back(CTxInUndo()); bool ret = inputs.ModifyCoins(txin.prevout.hash)->Spend(txin.prevout, txundo.vprevout.back()); assert(ret); @@ -3069,7 +3069,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin !((pindex->nHeight == 91842 && pindex->GetBlockHash() == uint256("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) || (pindex->nHeight == 91880 && pindex->GetBlockHash() == uint256("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"))); if (fEnforceBIP30) { - BOOST_FOREACH (const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { const CCoins* coins = view.AccessCoins(tx.GetHash()); if (coins && !coins->IsPruned()) return state.DoS(100, error("ConnectBlock() : tried to overwrite transaction"), @@ -3493,7 +3493,7 @@ bool static DisconnectTip(CValidationState& state) if (!FlushStateToDisk(state, FLUSH_STATE_ALWAYS)) return false; // Resurrect mempool transactions from the disconnected block. - BOOST_FOREACH (const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { // ignore validation errors in resurrected transactions list removed; CValidationState stateDummy; @@ -3506,7 +3506,7 @@ bool static DisconnectTip(CValidationState& state) UpdateTip(pindexDelete->pprev); // Let wallets know transactions went from 1-confirmed to // 0-confirmed or conflicted: - BOOST_FOREACH (const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { SyncWithWallets(tx, NULL); } return true; @@ -3581,11 +3581,11 @@ bool static ConnectTip(CValidationState& state, CBlockIndex* pindexNew, CBlock* UpdateTip(pindexNew); // Tell wallet about transactions that went from mempool // to conflicted: - BOOST_FOREACH (const CTransaction& tx, txConflicted) { + for (const CTransaction& tx : txConflicted) { SyncWithWallets(tx, NULL); } // ... and about transactions that got confirmed: - BOOST_FOREACH (const CTransaction& tx, pblock->vtx) { + for (const CTransaction& tx : pblock->vtx) { SyncWithWallets(tx, pblock); } @@ -3647,10 +3647,10 @@ bool DisconnectBlockAndInputs(CValidationState& state, CTransaction txLock) // Queue memory transactions to resurrect. // We only do this for blocks after the last checkpoint (reorganisation before that // point should only happen with -reindex/-loadblock, or a misbehaving peer. - BOOST_FOREACH (const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { if (!tx.IsCoinBase()) { - BOOST_FOREACH (const CTxIn& in1, txLock.vin) { - BOOST_FOREACH (const CTxIn& in2, tx.vin) { + for (const CTxIn& in1 : txLock.vin) { + for (const CTxIn& in2 : tx.vin) { if (in1.prevout == in2.prevout) foundConflictingTx = true; } } @@ -3671,7 +3671,7 @@ bool DisconnectBlockAndInputs(CValidationState& state, CTransaction txLock) if (vDisconnect.size() > 0) { LogPrintf("REORGANIZE: Disconnect Conflicting Blocks %lli blocks; %s..\n", vDisconnect.size(), pindexNew->GetBlockHash().ToString()); - BOOST_FOREACH (CBlockIndex* pindex, vDisconnect) { + for (CBlockIndex* pindex : vDisconnect) { LogPrintf(" -- disconnect %s\n", pindex->GetBlockHash().ToString()); DisconnectTip(state); } @@ -3866,7 +3866,7 @@ bool ActivateBestChain(CValidationState& state, CBlock* pblock, bool fAlreadyChe int nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(); { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (chainActive.Height() > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) pnode->PushInventory(CInv(MSG_BLOCK, hashNewTip)); } @@ -4240,10 +4240,10 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo // ----------- swiftTX transaction scanning ----------- if (IsSporkActive(SPORK_3_SWIFTTX_BLOCK_FILTERING)) { - BOOST_FOREACH (const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { if (!tx.IsCoinBase()) { //only reject blocks when it's based on complete consensus - BOOST_FOREACH (const CTxIn& in, tx.vin) { + for (const CTxIn& in : tx.vin) { if (mapLockedInputs.count(in.prevout)) { if (mapLockedInputs[in.prevout] != tx.GetHash()) { mapRejectedBlocks.insert(make_pair(block.GetHash(), GetTime())); @@ -4320,7 +4320,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo unsigned int nSigOps = 0; - BOOST_FOREACH (const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { nSigOps += GetLegacySigOpCount(tx); } unsigned int nMaxBlockSigOps = fZerocoinActive ? MAX_BLOCK_SIGOPS_CURRENT : MAX_BLOCK_SIGOPS_LEGACY; @@ -4445,7 +4445,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1; // Check that all transactions are finalized - BOOST_FOREACH (const CTransaction& tx, block.vtx) + for (const CTransaction& tx : block.vtx) if (!IsFinalTx(tx, nHeight, block.GetBlockTime())) { return state.DoS(10, error("%s : contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } @@ -5113,7 +5113,7 @@ bool static LoadBlockIndexDB(string& strError) vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex)); } sort(vSortedByHeight.begin(), vSortedByHeight.end()); - BOOST_FOREACH (const PAIRTYPE(int, CBlockIndex*) & item, vSortedByHeight) { + for (const PAIRTYPE(int, CBlockIndex*) & item : vSortedByHeight) { CBlockIndex* pindex = item.second; pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex); if (pindex->nStatus & BLOCK_HAVE_DATA) { @@ -5625,7 +5625,7 @@ string GetWarnings(string strFor) // Alerts { LOCK(cs_mapAlerts); - BOOST_FOREACH (PAIRTYPE(const uint256, CAlert) & item, mapAlerts) { + for (PAIRTYPE(const uint256, CAlert) & item : mapAlerts) { const CAlert& alert = item.second; if (alert.AppliesToMe() && alert.nPriority > nPriority) { nPriority = alert.nPriority; @@ -5770,7 +5770,7 @@ void static ProcessGetData(CNode* pfrom) // Thus, the protocol spec specified allows for us to provide duplicate txn here, // however we MUST always provide at least what the remote peer needs typedef std::pair PairType; - BOOST_FOREACH (PairType& pair, merkleBlock.vMatchedTxn) + for (PairType& pair : merkleBlock.vMatchedTxn) if (!pfrom->setInventoryKnown.count(CInv(MSG_TX, pair.second))) pfrom->PushMessage("tx", block.vtx[pair.first]); } @@ -6098,7 +6098,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // Relay alerts { LOCK(cs_mapAlerts); - BOOST_FOREACH (PAIRTYPE(const uint256, CAlert) & item, mapAlerts) + for (PAIRTYPE(const uint256, CAlert) & item : mapAlerts) item.second.RelayTo(pfrom); } @@ -6155,7 +6155,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, vector vAddrOk; int64_t nNow = GetAdjustedTime(); int64_t nSince = nNow - 10 * 60; - BOOST_FOREACH (CAddress& addr, vAddr) { + for (CAddress& addr : vAddr) { boost::this_thread::interruption_point(); if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) @@ -6175,7 +6175,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, uint256 hashRand = hashSalt ^ (hashAddr << 32) ^ ((GetTime() + hashAddr) / (24 * 60 * 60)); hashRand = Hash(BEGIN(hashRand), END(hashRand)); multimap mapMix; - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (pnode->nVersion < CADDR_TIME_VERSION) continue; unsigned int nPointer; @@ -6455,7 +6455,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } } - BOOST_FOREACH (uint256 hash, vEraseQueue)EraseOrphanTx(hash); + for (uint256 hash : vEraseQueue) EraseOrphanTx(hash); + } else if (tx.HasZerocoinSpendInputs() && AcceptToMemoryPool(mempool, state, tx, true, &fMissingZerocoinInputs, false, ignoreFees)) { //Presstab: ZCoin has a bunch of code commented out here. Is this something that should have more going on? //Also there is nothing that handles fMissingZerocoinInputs. Does there need to be? @@ -6522,7 +6523,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } CBlockIndex* pindexLast = NULL; - BOOST_FOREACH (const CBlockHeader& header, headers) { + for (const CBlockHeader& header : headers) { CValidationState state; if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) { Misbehaving(pfrom->GetId(), 20); @@ -6661,7 +6662,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else if ((strCommand == "getaddr") && (pfrom->fInbound)) { pfrom->vAddrToSend.clear(); vector vAddr = addrman.GetAddr(); - BOOST_FOREACH (const CAddress& addr, vAddr) + for (const CAddress& addr : vAddr) pfrom->PushAddress(addr); } @@ -6672,7 +6673,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, std::vector vtxid; mempool.queryHashes(vtxid); vector vInv; - BOOST_FOREACH (uint256& hash, vtxid) { + for (uint256& hash : vtxid) { CInv inv(MSG_TX, hash); CTransaction tx; bool fInMemPool = mempool.lookup(hash, tx); @@ -6777,7 +6778,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->setKnown.insert(alertHash); { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) alert.RelayTo(pnode); } } else { @@ -7057,7 +7058,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) static int64_t nLastRebroadcast; if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60)) { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { // Periodically clear setAddrKnown to allow refresh broadcasts if (nLastRebroadcast) pnode->setAddrKnown.clear(); @@ -7075,7 +7076,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) if (fSendTrickle) { vector vAddr; vAddr.reserve(pto->vAddrToSend.size()); - BOOST_FOREACH (const CAddress& addr, pto->vAddrToSend) { + for (const CAddress& addr : pto->vAddrToSend) { // returns true if wasn't already contained in the set if (pto->setAddrKnown.insert(addr).second) { vAddr.push_back(addr); @@ -7106,7 +7107,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) state.fShouldBan = false; } - BOOST_FOREACH (const CBlockReject& reject, state.rejects) + for (const CBlockReject& reject : state.rejects) pto->PushMessage("reject", (string) "block", reject.chRejectCode, reject.strRejectReason, reject.hashBlock); state.rejects.clear(); @@ -7142,7 +7143,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) LOCK(pto->cs_inventory); vInv.reserve(pto->vInventoryToSend.size()); vInvWait.reserve(pto->vInventoryToSend.size()); - BOOST_FOREACH (const CInv& inv, pto->vInventoryToSend) { + for (const CInv& inv : pto->vInventoryToSend) { if (pto->setInventoryKnown.count(inv)) continue; @@ -7203,7 +7204,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) vector vToDownload; NodeId staller = -1; FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller); - BOOST_FOREACH (CBlockIndex* pindex, vToDownload) { + for (CBlockIndex* pindex : vToDownload) { vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash())); MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex); LogPrintf("Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(), diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index 930690c9991ce..77b0f73d1f833 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -42,7 +42,7 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s findScript << OP_RETURN << ToByteVector(nExpectedHash); bool foundOpReturn = false; - BOOST_FOREACH (const CTxOut o, txCollateral.vout) { + for (const CTxOut o : txCollateral.vout) { if (!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()) { strError = strprintf("Invalid Script %s", txCollateral.ToString()); LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); @@ -970,7 +970,7 @@ void CBudgetManager::NewBlock() } LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->nVersion >= ActiveProtocol()) Sync(pnode, 0, true); @@ -2016,7 +2016,7 @@ std::string CFinalizedBudget::GetProposals() LOCK(cs); std::string ret = ""; - BOOST_FOREACH (CTxBudgetPayment& budgetPayment, vecBudgetPayments) { + for (CTxBudgetPayment& budgetPayment : vecBudgetPayments) { CBudgetProposal* pbudgetProposal = budget.FindProposal(budgetPayment.nProposalHash); std::string token = budgetPayment.nProposalHash.ToString(); @@ -2184,7 +2184,7 @@ TrxValidationStatus CFinalizedBudget::IsTransactionValid(const CTransaction& txN bool paid = false; - BOOST_FOREACH (CTxOut out, txNew.vout) { + for (CTxOut out : txNew.vout) { LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - nCurrentBudgetPayment=%d, payee=%s == out.scriptPubKey=%s, amount=%ld == out.nValue=%ld\n", nCurrentBudgetPayment, vecBudgetPayments[nCurrentBudgetPayment].payee.ToString().c_str(), out.scriptPubKey.ToString().c_str(), vecBudgetPayments[nCurrentBudgetPayment].nAmount, out.nValue); @@ -2262,7 +2262,7 @@ CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast(const CFinalizedBudget& oth { strBudgetName = other.strBudgetName; nBlockStart = other.nBlockStart; - BOOST_FOREACH (CTxBudgetPayment out, other.vecBudgetPayments) + for (CTxBudgetPayment out : other.vecBudgetPayments) vecBudgetPayments.push_back(out); mapVotes = other.mapVotes; nFeeTXHash = other.nFeeTXHash; @@ -2272,7 +2272,7 @@ CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast(std::string strBudgetNameIn { strBudgetName = strBudgetNameIn; nBlockStart = nBlockStartIn; - BOOST_FOREACH (CTxBudgetPayment out, vecBudgetPaymentsIn) + for (CTxBudgetPayment out : vecBudgetPaymentsIn) vecBudgetPayments.push_back(out); mapVotes.clear(); nFeeTXHash = nFeeTXHashIn; diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index e55c932eab4f2..a16080e1a7a4d 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -547,16 +547,16 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) CAmount requiredMasternodePayment = GetMasternodePayment(nBlockHeight, nReward, nMasternode_Drift_Count, txNew.HasZerocoinSpendInputs()); //require at least 6 signatures - BOOST_FOREACH (CMasternodePayee& payee, vecPayments) + for (CMasternodePayee& payee : vecPayments) if (payee.nVotes >= nMaxSignatures && payee.nVotes >= MNPAYMENTS_SIGNATURES_REQUIRED) nMaxSignatures = payee.nVotes; // if we don't have at least 6 signatures on a payee, approve whichever is the longest chain if (nMaxSignatures < MNPAYMENTS_SIGNATURES_REQUIRED) return true; - BOOST_FOREACH (CMasternodePayee& payee, vecPayments) { + for (CMasternodePayee& payee : vecPayments) { bool found = false; - BOOST_FOREACH (CTxOut out, txNew.vout) { + for (CTxOut out : txNew.vout) { if (payee.scriptPubKey == out.scriptPubKey) { if(out.nValue >= requiredMasternodePayment) found = true; @@ -590,7 +590,7 @@ std::string CMasternodeBlockPayees::GetRequiredPaymentsString() std::string ret = "Unknown"; - BOOST_FOREACH (CMasternodePayee& payee, vecPayments) { + for (CMasternodePayee& payee : vecPayments) { CTxDestination address1; ExtractDestination(payee.scriptPubKey, address1); CBitcoinAddress address2(address1); diff --git a/src/masternode-payments.h b/src/masternode-payments.h index 938b49e5d59b0..46b4aac4c01ba 100644 --- a/src/masternode-payments.h +++ b/src/masternode-payments.h @@ -107,7 +107,7 @@ class CMasternodeBlockPayees { LOCK(cs_vecPayments); - BOOST_FOREACH (CMasternodePayee& payee, vecPayments) { + for (CMasternodePayee& payee : vecPayments) { if (payee.scriptPubKey == payeeIn) { payee.nVotes += nIncrement; return; @@ -123,7 +123,7 @@ class CMasternodeBlockPayees LOCK(cs_vecPayments); int nVotes = -1; - BOOST_FOREACH (CMasternodePayee& p, vecPayments) { + for (CMasternodePayee& p : vecPayments) { if (p.nVotes > nVotes) { payee = p.scriptPubKey; nVotes = p.nVotes; @@ -137,7 +137,7 @@ class CMasternodeBlockPayees { LOCK(cs_vecPayments); - BOOST_FOREACH (CMasternodePayee& p, vecPayments) { + for (CMasternodePayee& p : vecPayments) { if (p.nVotes >= nVotesReq && p.scriptPubKey == payee) return true; } diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index e9915577fb7c9..e1d4eeb2bcb42 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -222,7 +222,7 @@ void CMasternodeSync::ClearFulfilledRequest() TRY_LOCK(cs_vNodes, lockRecv); if (!lockRecv) return; - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { pnode->ClearFulfilledRequest("getspork"); pnode->ClearFulfilledRequest("mnsync"); pnode->ClearFulfilledRequest("mnwsync"); @@ -264,7 +264,7 @@ void CMasternodeSync::Process() TRY_LOCK(cs_vNodes, lockRecv); if (!lockRecv) return; - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (Params().NetworkID() == CBaseChainParams::REGTEST) { if (RequestedMasternodeAttempt <= 2) { pnode->PushMessage("getsporks"); //get current network sporks diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index 2bd7dbd33df79..158dacd89f42c 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -234,7 +234,7 @@ void CMasternodeMan::Check() { LOCK(cs); - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { mn.Check(); } } @@ -354,7 +354,7 @@ int CMasternodeMan::stable_size () int64_t nMasternode_Min_Age = MN_WINNER_MINIMUM_AGE; int64_t nMasternode_Age = 0; - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { if (mn.protocolVersion < nMinProtocol) { continue; // Skip obsolete versions } @@ -379,7 +379,7 @@ int CMasternodeMan::CountEnabled(int protocolVersion) int i = 0; protocolVersion = protocolVersion == -1 ? masternodePayments.GetMinMasternodePaymentsProto() : protocolVersion; - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { mn.Check(); if (mn.protocolVersion < protocolVersion || !mn.IsEnabled()) continue; i++; @@ -392,7 +392,7 @@ void CMasternodeMan::CountNetworks(int protocolVersion, int& ipv4, int& ipv6, in { protocolVersion = protocolVersion == -1 ? masternodePayments.GetMinMasternodePaymentsProto() : protocolVersion; - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { mn.Check(); std::string strHost; int port; @@ -439,7 +439,7 @@ CMasternode* CMasternodeMan::Find(const CScript& payee) LOCK(cs); CScript payee2; - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { payee2 = GetScriptForDestination(mn.pubKeyCollateralAddress.GetID()); if (payee2 == payee) return &mn; @@ -451,7 +451,7 @@ CMasternode* CMasternodeMan::Find(const CTxIn& vin) { LOCK(cs); - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { if (mn.vin.prevout == vin.prevout) return &mn; } @@ -463,7 +463,7 @@ CMasternode* CMasternodeMan::Find(const CPubKey& pubKeyMasternode) { LOCK(cs); - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { if (mn.pubKeyMasternode == pubKeyMasternode) return &mn; } @@ -485,7 +485,7 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight */ int nMnCount = CountEnabled(); - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { mn.Check(); if (!mn.IsEnabled()) continue; @@ -519,7 +519,7 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight int nTenthNetwork = CountEnabled() / 10; int nCountTenth = 0; uint256 nHigh = 0; - BOOST_FOREACH (PAIRTYPE(int64_t, CTxIn) & s, vecMasternodeLastPaid) { + for (PAIRTYPE(int64_t, CTxIn) & s : vecMasternodeLastPaid) { CMasternode* pmn = Find(s.second); if (!pmn) break; @@ -548,10 +548,10 @@ CMasternode* CMasternodeMan::FindRandomNotInVec(std::vector& vecToExclude LogPrint("masternode", "CMasternodeMan::FindRandomNotInVec - rand %d\n", rand); bool found; - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { if (mn.protocolVersion < protocolVersion || !mn.IsEnabled()) continue; found = false; - BOOST_FOREACH (CTxIn& usedVin, vecToExclude) { + for (CTxIn& usedVin : vecToExclude) { if (mn.vin.prevout == usedVin.prevout) { found = true; break; @@ -572,7 +572,7 @@ CMasternode* CMasternodeMan::GetCurrentMasterNode(int mod, int64_t nBlockHeight, CMasternode* winner = NULL; // scan for winner - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { mn.Check(); if (mn.protocolVersion < minProtocol || !mn.IsEnabled()) continue; @@ -601,7 +601,7 @@ int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, in if (!GetBlockHash(hash, nBlockHeight)) return -1; // scan for winner - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { if (mn.protocolVersion < minProtocol) { LogPrint("masternode","Skipping Masternode with obsolete version %d\n", mn.protocolVersion); continue; // Skip obsolete versions @@ -627,7 +627,7 @@ int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, in sort(vecMasternodeScores.rbegin(), vecMasternodeScores.rend(), CompareScoreTxIn()); int rank = 0; - BOOST_FOREACH (PAIRTYPE(int64_t, CTxIn) & s, vecMasternodeScores) { + for (PAIRTYPE(int64_t, CTxIn) & s : vecMasternodeScores) { rank++; if (s.second.prevout == vin.prevout) { return rank; @@ -647,7 +647,7 @@ std::vector > CMasternodeMan::GetMasternodeRanks(int64_t if (!GetBlockHash(hash, nBlockHeight)) return vecMasternodeRanks; // scan for winner - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { mn.Check(); if (mn.protocolVersion < minProtocol) continue; @@ -666,7 +666,7 @@ std::vector > CMasternodeMan::GetMasternodeRanks(int64_t sort(vecMasternodeScores.rbegin(), vecMasternodeScores.rend(), CompareScoreMN()); int rank = 0; - BOOST_FOREACH (PAIRTYPE(int64_t, CMasternode) & s, vecMasternodeScores) { + for (PAIRTYPE(int64_t, CMasternode) & s : vecMasternodeScores) { rank++; vecMasternodeRanks.push_back(make_pair(rank, s.second)); } @@ -679,7 +679,7 @@ CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int64_t nBlockHeight std::vector > vecMasternodeScores; // scan for winner - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { if (mn.protocolVersion < minProtocol) continue; if (fOnlyActive) { mn.Check(); @@ -695,7 +695,7 @@ CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int64_t nBlockHeight sort(vecMasternodeScores.rbegin(), vecMasternodeScores.rend(), CompareScoreTxIn()); int rank = 0; - BOOST_FOREACH (PAIRTYPE(int64_t, CTxIn) & s, vecMasternodeScores) { + for (PAIRTYPE(int64_t, CTxIn) & s : vecMasternodeScores) { rank++; if (rank == nRank) { return Find(s.second); @@ -711,7 +711,7 @@ void CMasternodeMan::ProcessMasternodeConnections() if (Params().NetworkID() == CBaseChainParams::REGTEST) return; LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (pnode->fObfuScationMaster) { if (obfuScationPool.pSubmittedToMasternode != NULL && pnode->addr == obfuScationPool.pSubmittedToMasternode->addr) continue; LogPrint("masternode","Closing Masternode connection peer=%i \n", pnode->GetId()); @@ -822,7 +822,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData int nInvCount = 0; - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { if (mn.addr.IsRFC1918()) continue; //local network if (mn.IsEnabled()) { @@ -953,7 +953,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData if (pmn->IsEnabled()) { TRY_LOCK(cs_vNodes, lockNodes); if (!lockNodes) return; - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->nVersion >= masternodePayments.GetMinMasternodePaymentsProto()) pnode->PushMessage("dsee", vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated, protocolVersion, donationAddress, donationPercentage); } @@ -1042,7 +1042,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData if (mn.IsEnabled()) { TRY_LOCK(cs_vNodes, lockNodes); if (!lockNodes) return; - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->nVersion >= masternodePayments.GetMinMasternodePaymentsProto()) pnode->PushMessage("dsee", vin, addr, vchSig, sigTime, pubkey, pubkey2, count, current, lastUpdated, protocolVersion, donationAddress, donationPercentage); } @@ -1112,7 +1112,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData TRY_LOCK(cs_vNodes, lockNodes); if (!lockNodes) return; LogPrint("masternode", "dseep - relaying %s \n", vin.prevout.hash.ToString()); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->nVersion >= masternodePayments.GetMinMasternodePaymentsProto()) pnode->PushMessage("dseep", vin, vchSig, sigTime, stop); } diff --git a/src/miner.cpp b/src/miner.cpp index b92a30085c4de..09886777ac518 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -426,7 +426,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, // Add transactions that depend on this one to the priority queue if (mapDependers.count(hash)) { - BOOST_FOREACH (COrphan* porphan, mapDependers[hash]) { + for (COrphan* porphan : mapDependers[hash]) { if (!porphan->setDependsOn.empty()) { porphan->setDependsOn.erase(hash); if (porphan->setDependsOn.empty()) { diff --git a/src/net.cpp b/src/net.cpp index 62138ce85559b..3b7c5ed8776c8 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -566,7 +566,7 @@ void CNode::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t banti uiInterface.BannedListChanged(); { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (subNet.Match((CNetAddr)pnode->addr)) pnode->fDisconnect = true; } @@ -655,7 +655,7 @@ CCriticalSection CNode::cs_vWhitelistedRange; bool CNode::IsWhitelistedRange(const CNetAddr& addr) { LOCK(cs_vWhitelistedRange); - BOOST_FOREACH (const CSubNet& subnet, vWhitelistedRange) { + for (const CSubNet& subnet : vWhitelistedRange) { if (subnet.Match(addr)) return true; } @@ -848,7 +848,7 @@ void ThreadSocketHandler() LOCK(cs_vNodes); // Disconnect unused nodes vector vNodesCopy = vNodes; - BOOST_FOREACH (CNode* pnode, vNodesCopy) { + for (CNode* pnode : vNodesCopy) { if (pnode->fDisconnect || (pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty())) { // remove from vNodes @@ -870,7 +870,7 @@ void ThreadSocketHandler() { // Delete disconnected nodes list vNodesDisconnectedCopy = vNodesDisconnected; - BOOST_FOREACH (CNode* pnode, vNodesDisconnectedCopy) { + for (CNode* pnode : vNodesDisconnectedCopy) { // wait until threads are done using it if (pnode->GetRefCount() <= 0) { bool fDelete = false; @@ -918,7 +918,7 @@ void ThreadSocketHandler() SOCKET hSocketMax = 0; bool have_fds = false; - BOOST_FOREACH (const ListenSocket& hListenSocket, vhListenSocket) { + for (const ListenSocket& hListenSocket : vhListenSocket) { FD_SET(hListenSocket.socket, &fdsetRecv); hSocketMax = max(hSocketMax, hListenSocket.socket); have_fds = true; @@ -926,7 +926,7 @@ void ThreadSocketHandler() { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (pnode->hSocket == INVALID_SOCKET) continue; FD_SET(pnode->hSocket, &fdsetError); @@ -983,7 +983,7 @@ void ThreadSocketHandler() // // Accept new connections // - BOOST_FOREACH (const ListenSocket& hListenSocket, vhListenSocket) { + for (const ListenSocket& hListenSocket : vhListenSocket) { if (hListenSocket.socket != INVALID_SOCKET && FD_ISSET(hListenSocket.socket, &fdsetRecv)) { struct sockaddr_storage sockaddr; socklen_t len = sizeof(sockaddr); @@ -998,7 +998,7 @@ void ThreadSocketHandler() bool whitelisted = hListenSocket.whitelisted || CNode::IsWhitelistedRange(addr); { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->fInbound) nInbound++; } @@ -1036,10 +1036,10 @@ void ThreadSocketHandler() { LOCK(cs_vNodes); vNodesCopy = vNodes; - BOOST_FOREACH (CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) pnode->AddRef(); } - BOOST_FOREACH (CNode* pnode, vNodesCopy) { + for (CNode* pnode : vNodesCopy) { boost::this_thread::interruption_point(); // @@ -1111,7 +1111,7 @@ void ThreadSocketHandler() } { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) pnode->Release(); } } @@ -1246,14 +1246,14 @@ void ThreadDNSAddressSeed() LogPrintf("Loading addresses from DNS seeds (could take a while)\n"); - BOOST_FOREACH (const CDNSSeedData& seed, vSeeds) { + for (const CDNSSeedData& seed : vSeeds) { if (HaveNameProxy()) { AddOneShot(seed.host); } else { vector vIPs; vector vAdd; if (LookupHost(seed.host.c_str(), vIPs)) { - BOOST_FOREACH (CNetAddr& ip, vIPs) { + for (CNetAddr& ip : vIPs) { int nOneDay = 24 * 3600; CAddress addr = CAddress(CService(ip, Params().GetDefaultPort())); addr.nTime = GetTime() - 3 * nOneDay - GetRand(4 * nOneDay); // use a random age between 3 and 7 days old @@ -1310,7 +1310,7 @@ void ThreadOpenConnections() if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { for (int64_t nLoop = 0;; nLoop++) { ProcessOneShot(); - BOOST_FOREACH (string strAddr, mapMultiArgs["-connect"]) { + for (string strAddr : mapMultiArgs["-connect"]) { CAddress addr; OpenNetworkConnection(addr, NULL, strAddr.c_str()); for (int i = 0; i < 10 && i < nLoop; i++) { @@ -1352,7 +1352,7 @@ void ThreadOpenConnections() set > setConnected; { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (!pnode->fInbound) { setConnected.insert(pnode->addr.GetGroup()); nOutbound++; @@ -1409,10 +1409,10 @@ void ThreadOpenAddedConnections() list lAddresses(0); { LOCK(cs_vAddedNodes); - BOOST_FOREACH (string& strAddNode, vAddedNodes) + for (string& strAddNode : vAddedNodes) lAddresses.push_back(strAddNode); } - BOOST_FOREACH (string& strAddNode, lAddresses) { + for (string& strAddNode : lAddresses) { CAddress addr; CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(addr, &grant, strAddNode.c_str()); @@ -1426,18 +1426,18 @@ void ThreadOpenAddedConnections() list lAddresses(0); { LOCK(cs_vAddedNodes); - BOOST_FOREACH (string& strAddNode, vAddedNodes) + for (string& strAddNode : vAddedNodes) lAddresses.push_back(strAddNode); } list > lservAddressesToAdd(0); - BOOST_FOREACH (string& strAddNode, lAddresses) { + for (string& strAddNode : lAddresses) { vector vservNode(0); if (Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0)) { lservAddressesToAdd.push_back(vservNode); { LOCK(cs_setservAddNodeAddresses); - BOOST_FOREACH (CService& serv, vservNode) + for (CService& serv : vservNode) setservAddNodeAddresses.insert(serv); } } @@ -1446,16 +1446,16 @@ void ThreadOpenAddedConnections() // (keeping in mind that addnode entries can have many IPs if fNameLookup) { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) for (list >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++) - BOOST_FOREACH (CService& addrNode, *(it)) + for (CService& addrNode : *(it)) if (pnode->addr == addrNode) { it = lservAddressesToAdd.erase(it); it--; break; } } - BOOST_FOREACH (vector& vserv, lservAddressesToAdd) { + for (vector& vserv : lservAddressesToAdd) { CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant); MilliSleep(500); @@ -1505,7 +1505,7 @@ void ThreadMessageHandler() { LOCK(cs_vNodes); vNodesCopy = vNodes; - BOOST_FOREACH (CNode* pnode, vNodesCopy) { + for (CNode* pnode : vNodesCopy) { pnode->AddRef(); } } @@ -1517,7 +1517,7 @@ void ThreadMessageHandler() bool fSleep = true; - BOOST_FOREACH (CNode* pnode, vNodesCopy) { + for (CNode* pnode : vNodesCopy) { if (pnode->fDisconnect) continue; @@ -1549,7 +1549,7 @@ void ThreadMessageHandler() { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) pnode->Release(); } @@ -1676,7 +1676,7 @@ void static Discover(boost::thread_group& threadGroup) if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) { vector vaddr; if (LookupHost(pszHostName, vaddr)) { - BOOST_FOREACH (const CNetAddr& addr, vaddr) { + for (const CNetAddr& addr : vaddr) { if (AddLocal(addr, LOCAL_IF)) LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString()); } @@ -1806,18 +1806,18 @@ class CNetCleanup ~CNetCleanup() { // Close sockets - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->hSocket != INVALID_SOCKET) CloseSocket(pnode->hSocket); - BOOST_FOREACH (ListenSocket& hListenSocket, vhListenSocket) + for (ListenSocket& hListenSocket : vhListenSocket) if (hListenSocket.socket != INVALID_SOCKET) if (!CloseSocket(hListenSocket.socket)) LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError())); // clean up some globals (to help leak detection) - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) delete pnode; - BOOST_FOREACH (CNode* pnode, vNodesDisconnected) + for (CNode* pnode : vNodesDisconnected) delete pnode; vNodes.clear(); vNodesDisconnected.clear(); @@ -1866,7 +1866,7 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss) vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv)); } LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (!pnode->fRelayTxes) continue; LOCK(pnode->cs_filter); @@ -1884,7 +1884,7 @@ void RelayTransactionLockReq(const CTransaction& tx, bool relayToAll) //broadcast the new lock LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (!relayToAll && !pnode->fRelayTxes) continue; @@ -1895,7 +1895,7 @@ void RelayTransactionLockReq(const CTransaction& tx, bool relayToAll) void RelayInv(CInv& inv) { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes){ + for (CNode* pnode : vNodes){ if((pnode->nServices == NODE_BLOOM_WITHOUT_MN || pnode->nServices == NODE_BLOOM_LIGHT_ZC) && inv.IsMasterNodeType())continue; if (pnode->nVersion >= ActiveProtocol()) pnode->PushInventory(inv); diff --git a/src/net.h b/src/net.h index 406f2d91fa8b1..2f0b2f9bbf9eb 100644 --- a/src/net.h +++ b/src/net.h @@ -411,7 +411,7 @@ class CNode unsigned int GetTotalRecvSize() { unsigned int total = 0; - BOOST_FOREACH (const CNetMessage& msg, vRecvMsg) + for (const CNetMessage& msg : vRecvMsg) total += msg.vRecv.size() + 24; return total; } @@ -423,7 +423,7 @@ class CNode void SetRecvVersion(int nVersionIn) { nRecvVersion = nVersionIn; - BOOST_FOREACH (CNetMessage& msg, vRecvMsg) + for (CNetMessage& msg : vRecvMsg) msg.SetVersion(nVersionIn); } @@ -659,7 +659,7 @@ class CNode bool HasFulfilledRequest(std::string strRequest) { - BOOST_FOREACH (std::string& type, vecRequestsFulfilled) { + for (std::string& type : vecRequestsFulfilled) { if (type == strRequest) return true; } return false; diff --git a/src/obfuscation.cpp b/src/obfuscation.cpp index 66ac47f636709..652d6aafe7d0a 100644 --- a/src/obfuscation.cpp +++ b/src/obfuscation.cpp @@ -131,7 +131,7 @@ void CObfuscationPool::ProcessMessageObfuscation(CNode* pfrom, std::string& strC PrepareObfuscationDenominate(); } } else { - BOOST_FOREACH (CObfuscationQueue q, vecObfuscationQueue) { + for (CObfuscationQueue q : vecObfuscationQueue) { if (q.vin == dsq.vin) return; } @@ -202,7 +202,7 @@ void CObfuscationPool::ProcessMessageObfuscation(CNode* pfrom, std::string& strC CValidationState state; CMutableTransaction tx; - BOOST_FOREACH (const CTxOut o, out) { + for (const CTxOut o : out) { nValueOut += o.nValue; tx.vout.push_back(o); @@ -220,7 +220,7 @@ void CObfuscationPool::ProcessMessageObfuscation(CNode* pfrom, std::string& strC } } - BOOST_FOREACH (const CTxIn i, in) { + for (const CTxIn i : in) { tx.vin.push_back(i); LogPrint("obfuscation", "dsi -- tx in %s\n", i.ToString()); @@ -316,7 +316,7 @@ void CObfuscationPool::ProcessMessageObfuscation(CNode* pfrom, std::string& strC bool success = false; int count = 0; - BOOST_FOREACH (const CTxIn item, sigs) { + for (const CTxIn item : sigs) { if (AddScriptSig(item)) success = true; LogPrint("obfuscation", " -- sigs count %d %d\n", (int)sigs.size(), count); count++; @@ -439,7 +439,7 @@ void CObfuscationPool::UnlockCoins() MilliSleep(50); continue; } - BOOST_FOREACH (CTxIn v, lockedCoins) + for (CTxIn v : lockedCoins) pwalletMain->UnlockCoin(v.prevout); break; } @@ -541,10 +541,10 @@ void CObfuscationPool::Check() // make our new transaction for (unsigned int i = 0; i < entries.size(); i++) { - BOOST_FOREACH (const CTxOut& v, entries[i].vout) + for (const CTxOut& v : entries[i].vout) txNew.vout.push_back(v); - BOOST_FOREACH (const CTxDSIn& s, entries[i].sev) + for (const CTxDSIn& s : entries[i].sev) txNew.vin.push_back(s); } @@ -673,9 +673,9 @@ void CObfuscationPool::ChargeFees() if (r > 33) return; if (state == POOL_STATUS_ACCEPTING_ENTRIES) { - BOOST_FOREACH (const CTransaction& txCollateral, vecSessionCollateral) { + for (const CTransaction& txCollateral : vecSessionCollateral) { bool found = false; - BOOST_FOREACH (const CObfuScationEntry& v, entries) { + for (const CObfuScationEntry& v : entries) { if (v.collateral == txCollateral) { found = true; } @@ -691,8 +691,8 @@ void CObfuscationPool::ChargeFees() if (state == POOL_STATUS_SIGNING) { // who didn't sign? - BOOST_FOREACH (const CObfuScationEntry v, entries) { - BOOST_FOREACH (const CTxDSIn s, v.sev) { + for (const CObfuScationEntry v : entries) { + for (const CTxDSIn s : v.sev) { if (!s.fHasSig) { LogPrintf("CObfuscationPool::ChargeFees -- found uncooperative node (didn't sign). Found offence\n"); offences++; @@ -717,9 +717,9 @@ void CObfuscationPool::ChargeFees() r = rand() % 100; if (state == POOL_STATUS_ACCEPTING_ENTRIES) { - BOOST_FOREACH (const CTransaction& txCollateral, vecSessionCollateral) { + for (const CTransaction& txCollateral : vecSessionCollateral) { bool found = false; - BOOST_FOREACH (const CObfuScationEntry& v, entries) { + for (const CObfuScationEntry& v : entries) { if (v.collateral == txCollateral) { found = true; } @@ -744,8 +744,8 @@ void CObfuscationPool::ChargeFees() if (state == POOL_STATUS_SIGNING) { // who didn't sign? - BOOST_FOREACH (const CObfuScationEntry v, entries) { - BOOST_FOREACH (const CTxDSIn s, v.sev) { + for (const CObfuScationEntry v : entries) { + for (const CTxDSIn s : v.sev) { if (!s.fHasSig && r > target) { LogPrintf("CObfuscationPool::ChargeFees -- found uncooperative node (didn't sign). charging fees.\n"); @@ -771,7 +771,7 @@ void CObfuscationPool::ChargeRandomFees() if (fMasterNode) { int i = 0; - BOOST_FOREACH (const CTransaction& txCollateral, vecSessionCollateral) { + for (const CTransaction& txCollateral : vecSessionCollateral) { int r = rand() % 100; /* @@ -920,11 +920,11 @@ bool CObfuscationPool::SignatureValid(const CScript& newSig, const CTxIn& newVin CScript sigPubKey = CScript(); unsigned int i = 0; - BOOST_FOREACH (CObfuScationEntry& e, entries) { - BOOST_FOREACH (const CTxOut& out, e.vout) + for (CObfuScationEntry& e : entries) { + for (const CTxOut& out : e.vout) txNew.vout.push_back(out); - BOOST_FOREACH (const CTxDSIn& s, e.sev) { + for (const CTxDSIn& s : e.sev) { txNew.vin.push_back(s); if (s == newVin) { @@ -959,7 +959,7 @@ bool CObfuscationPool::IsCollateralValid(const CTransaction& txCollateral) int64_t nValueOut = 0; bool missingTx = false; - BOOST_FOREACH (const CTxOut o, txCollateral.vout) { + for (const CTxOut o : txCollateral.vout) { nValueOut += o.nValue; if (!o.scriptPubKey.IsNormalPaymentScript()) { @@ -968,7 +968,7 @@ bool CObfuscationPool::IsCollateralValid(const CTransaction& txCollateral) } } - BOOST_FOREACH (const CTxIn i, txCollateral.vin) { + for (const CTxIn i : txCollateral.vin) { CTransaction tx2; uint256 hash; if (GetTransaction(i.prevout.hash, tx2, hash, true)) { @@ -1013,7 +1013,7 @@ bool CObfuscationPool::AddEntry(const std::vector& newInput, const CAmoun { if (!fMasterNode) return false; - BOOST_FOREACH (CTxIn in, newInput) { + for (CTxIn in : newInput) { if (in.prevout.IsNull() || nAmount < 0) { LogPrint("obfuscation", "CObfuscationPool::AddEntry - input not valid!\n"); errorID = ERR_INVALID_INPUT; @@ -1036,10 +1036,10 @@ bool CObfuscationPool::AddEntry(const std::vector& newInput, const CAmoun return false; } - BOOST_FOREACH (CTxIn in, newInput) { + for (CTxIn in : newInput) { LogPrint("obfuscation", "looking for vin -- %s\n", in.ToString()); - BOOST_FOREACH (const CObfuScationEntry& v, entries) { - BOOST_FOREACH (const CTxDSIn& s, v.sev) { + for (const CObfuScationEntry& v : entries) { + for (const CTxDSIn& s : v.sev) { if ((CTxIn)s == in) { LogPrint("obfuscation", "CObfuscationPool::AddEntry - found in vin\n"); errorID = ERR_ALREADY_HAVE; @@ -1065,8 +1065,8 @@ bool CObfuscationPool::AddScriptSig(const CTxIn& newVin) LogPrint("obfuscation", "CObfuscationPool::AddScriptSig -- new sig %s\n", newVin.scriptSig.ToString().substr(0, 24)); - BOOST_FOREACH (const CObfuScationEntry& v, entries) { - BOOST_FOREACH (const CTxDSIn& s, v.sev) { + for (const CObfuScationEntry& v : entries) { + for (const CTxDSIn& s : v.sev) { if (s.scriptSig == newVin.scriptSig) { LogPrint("obfuscation", "CObfuscationPool::AddScriptSig - already exists\n"); return false; @@ -1081,7 +1081,7 @@ bool CObfuscationPool::AddScriptSig(const CTxIn& newVin) LogPrint("obfuscation", "CObfuscationPool::AddScriptSig -- sig %s\n", newVin.ToString()); - BOOST_FOREACH (CTxIn& vin, finalTransaction.vin) { + for (CTxIn& vin : finalTransaction.vin) { if (newVin.prevout == vin.prevout && vin.nSequence == newVin.nSequence) { vin.scriptSig = newVin.scriptSig; vin.prevPubKey = newVin.prevPubKey; @@ -1102,8 +1102,8 @@ bool CObfuscationPool::AddScriptSig(const CTxIn& newVin) // Check to make sure everything is signed bool CObfuscationPool::SignaturesComplete() { - BOOST_FOREACH (const CObfuScationEntry& v, entries) { - BOOST_FOREACH (const CTxDSIn& s, v.sev) { + for (const CObfuScationEntry& v : entries) { + for (const CTxDSIn& s : v.sev) { if (!s.fHasSig) return false; } } @@ -1127,13 +1127,13 @@ void CObfuscationPool::SendObfuscationDenominate(std::vector& vin, std::v } // lock the funds we're going to use - BOOST_FOREACH (CTxIn in, txCollateral.vin) + for (CTxIn in : txCollateral.vin) lockedCoins.push_back(in); - BOOST_FOREACH (CTxIn in, vin) + for (CTxIn in : vin) lockedCoins.push_back(in); - //BOOST_FOREACH(CTxOut o, vout) + //for (CTxOut o : vout) // LogPrintf(" vout - %s\n", o.ToString()); @@ -1166,12 +1166,12 @@ void CObfuscationPool::SendObfuscationDenominate(std::vector& vin, std::v CValidationState state; CMutableTransaction tx; - BOOST_FOREACH (const CTxOut& o, vout) { + for (const CTxOut& o : vout) { nValueOut += o.nValue; tx.vout.push_back(o); } - BOOST_FOREACH (const CTxIn& i, vin) { + for (const CTxIn& i : vin) { tx.vin.push_back(i); LogPrint("obfuscation", "dsi -- tx in %s\n", i.ToString()); @@ -1267,8 +1267,8 @@ bool CObfuscationPool::SignFinalTransaction(CTransaction& finalTransactionNew, C vector sigs; //make sure my inputs/outputs are present, otherwise refuse to sign - BOOST_FOREACH (const CObfuScationEntry e, entries) { - BOOST_FOREACH (const CTxDSIn s, e.sev) { + for (const CObfuScationEntry e : entries) { + for (const CTxDSIn s : e.sev) { /* Sign my transaction and all outputs */ int mine = -1; CScript prevPubKey = CScript(); @@ -1288,7 +1288,7 @@ bool CObfuscationPool::SignFinalTransaction(CTransaction& finalTransactionNew, C CAmount nValue2 = 0; for (unsigned int i = 0; i < finalTransaction.vout.size(); i++) { - BOOST_FOREACH (const CTxOut& o, e.vout) { + for (const CTxOut& o : e.vout) { if (finalTransaction.vout[i] == o) { foundOutputs++; nValue1 += finalTransaction.vout[i].nValue; @@ -1296,7 +1296,7 @@ bool CObfuscationPool::SignFinalTransaction(CTransaction& finalTransactionNew, C } } - BOOST_FOREACH (const CTxOut o, e.vout) + for (const CTxOut o : e.vout) nValue2 += o.nValue; int targetOuputs = e.vout.size(); @@ -1532,7 +1532,7 @@ bool CObfuscationPool::DoAutomaticDenominating(bool fDryRun) //don't use the queues all of the time for mixing if (nUseQueue > 33) { // Look through the queues and see if anything matches - BOOST_FOREACH (CObfuscationQueue& dsq, vecObfuscationQueue) { + for (CObfuscationQueue& dsq : vecObfuscationQueue) { CService addr; if (dsq.time == 0) continue; @@ -1548,7 +1548,7 @@ bool CObfuscationPool::DoAutomaticDenominating(bool fDryRun) bool fUsed = false; //don't reuse Masternodes - BOOST_FOREACH (CTxIn usedVin, vecMasternodesUsed) { + for (CTxIn usedVin : vecMasternodesUsed) { if (dsq.vin == usedVin) { fUsed = true; break; @@ -1843,13 +1843,13 @@ bool CObfuscationPool::IsCompatibleWithEntries(std::vector& vout) { if (GetDenominations(vout) == 0) return false; - BOOST_FOREACH (const CObfuScationEntry v, entries) { + for (const CObfuScationEntry v : entries) { LogPrintf(" IsCompatibleWithEntries %d %d\n", GetDenominations(vout), GetDenominations(v.vout)); /* - BOOST_FOREACH(CTxOut o1, vout) + for (CTxOut o1 : vout) LogPrintf(" vout 1 - %s\n", o1.ToString()); - BOOST_FOREACH(CTxOut o2, v.vout) + for (CTxOut o2 : v.vout) LogPrintf(" vout 2 - %s\n", o2.ToString()); */ if (GetDenominations(vout) != GetDenominations(v.vout)) return false; @@ -1953,7 +1953,7 @@ int CObfuscationPool::GetDenominations(const std::vector& vout) { std::vector vout2; - BOOST_FOREACH (CTxDSOut out, vout) + for (CTxDSOut out : vout) vout2.push_back(out); return GetDenominations(vout2); @@ -1965,13 +1965,13 @@ int CObfuscationPool::GetDenominations(const std::vector& vout, bool fSi std::vector > denomUsed; // make a list of denominations, with zero uses - BOOST_FOREACH (int64_t d, obfuScationDenominations) + for (int64_t d : obfuScationDenominations) denomUsed.push_back(make_pair(d, 0)); // look for denominations and update uses to 1 - BOOST_FOREACH (CTxOut out, vout) { + for (CTxOut out : vout) { bool found = false; - BOOST_FOREACH (PAIRTYPE(int64_t, int) & s, denomUsed) { + for (PAIRTYPE(int64_t, int) & s : denomUsed) { if (out.nValue == s.first) { s.second = 1; found = true; @@ -1984,7 +1984,7 @@ int CObfuscationPool::GetDenominations(const std::vector& vout, bool fSi int c = 0; // if the denomination is used, shift the bit on. // then move to the next - BOOST_FOREACH (PAIRTYPE(int64_t, int) & s, denomUsed) { + for (PAIRTYPE(int64_t, int) & s : denomUsed) { int bit = (fSingleRandomDenom ? rand() % 2 : 1) * s.second; denom |= bit << c++; if (fSingleRandomDenom && bit) break; // use just one random denomination @@ -2112,7 +2112,7 @@ bool CObfuScationSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey) CTransaction txVin; uint256 hash; if (GetTransaction(vin.prevout.hash, txVin, hash, true)) { - BOOST_FOREACH (CTxOut out, txVin.vout) { + for (CTxOut out : txVin.vout) { if (out.nValue == 10000 * COIN) { if (out.scriptPubKey == payee2) return true; } @@ -2213,7 +2213,7 @@ bool CObfuscationQueue::Sign() bool CObfuscationQueue::Relay() { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { // always relay to everyone pnode->PushMessage("dsq", (*this)); } @@ -2243,7 +2243,7 @@ bool CObfuscationQueue::CheckSignature() void CObfuscationPool::RelayFinalTransaction(const int sessionID, const CTransaction& txNew) { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { pnode->PushMessage("dsf", sessionID, txNew); } } @@ -2255,10 +2255,10 @@ void CObfuscationPool::RelayIn(const std::vector& vin, const int64_t& n std::vector vin2; std::vector vout2; - BOOST_FOREACH (CTxDSIn in, vin) + for (CTxDSIn in : vin) vin2.push_back(in); - BOOST_FOREACH (CTxDSOut out, vout) + for (CTxDSOut out : vout) vout2.push_back(out); CNode* pnode = FindNode(pSubmittedToMasternode->addr); @@ -2271,14 +2271,14 @@ void CObfuscationPool::RelayIn(const std::vector& vin, const int64_t& n void CObfuscationPool::RelayStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const int errorID) { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) pnode->PushMessage("dssu", sessionID, newState, newEntriesCount, newAccepted, errorID); } void CObfuscationPool::RelayCompletedTransaction(const int sessionID, const bool error, const int errorID) { LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) pnode->PushMessage("dsc", sessionID, error, errorID); } diff --git a/src/obfuscation.h b/src/obfuscation.h index 0663e3d50773d..172f01e35fc67 100644 --- a/src/obfuscation.h +++ b/src/obfuscation.h @@ -117,10 +117,10 @@ class CObfuScationEntry return false; } - BOOST_FOREACH (const CTxIn& in, vinIn) + for (const CTxIn& in : vinIn) sev.push_back(in); - BOOST_FOREACH (const CTxOut& out, voutIn) + for (const CTxOut& out : voutIn) vout.push_back(out); amount = amountIn; @@ -133,7 +133,7 @@ class CObfuScationEntry bool AddSig(const CTxIn& vin) { - BOOST_FOREACH (CTxDSIn& s, sev) { + for (CTxDSIn& s : sev) { if (s.prevout == vin.prevout && s.nSequence == vin.nSequence) { if (s.fHasSig) { return false; diff --git a/src/pivx-tx.cpp b/src/pivx-tx.cpp index 031370e0f097b..9c4d6f8caf927 100644 --- a/src/pivx-tx.cpp +++ b/src/pivx-tx.cpp @@ -432,7 +432,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr) SignSignature(keystore, prevPubKey, mergedTx, i, nHashType); // ... and merge in other signatures: - BOOST_FOREACH (const CTransaction& txv, txVariants) { + for (const CTransaction& txv : txVariants) { txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig); } if (!VerifyScript(txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&mergedTx, i))) diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index 1e60c131dabea..da051cd5d94b4 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -82,7 +82,7 @@ class AddressTablePriv cachedAddressTable.clear(); { LOCK(wallet->cs_wallet); - BOOST_FOREACH (const PAIRTYPE(CTxDestination, CAddressBookData) & item, wallet->mapAddressBook) { + for (const PAIRTYPE(CTxDestination, CAddressBookData) & item : wallet->mapAddressBook) { const CBitcoinAddress& address = item.first; bool fMine = IsMine(*wallet, address.Get()); AddressTableEntry::Type addressType = translateTransactionType( diff --git a/src/qt/blockexplorer.cpp b/src/qt/blockexplorer.cpp index 88fde0ad1584d..977c72a735ea5 100644 --- a/src/qt/blockexplorer.cpp +++ b/src/qt/blockexplorer.cpp @@ -405,7 +405,7 @@ std::string AddressToString(const CBitcoinAddress& Address) { std::vector Txs; paddressmap->GetTxs(Txs, AddressScript.GetID()); - BOOST_FOREACH (const CDiskTxPos& pos, Txs) + for (const CDiskTxPos& pos : Txs) { CTransaction tx; CBlock block; diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 68598f39f87b4..b5a5907c54ce8 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -65,7 +65,7 @@ int ClientModel::getNumConnections(unsigned int flags) const return vNodes.size(); int nNum = 0; - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT)) nNum++; diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 28191e7b812c9..7801adba93a12 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -559,7 +559,7 @@ void CoinControlDialog::updateLabels(WalletModel* model, QDialog* dialog) coinControl->ListSelected(vCoinControl); model->getOutputs(vCoinControl, vOutputs); - BOOST_FOREACH (const COutput& out, vOutputs) { + for (const COutput& out : vOutputs) { // unselect already spent, very unlikely scenario, this could happen // when selected are spent elsewhere, like rpc or another computer uint256 txhash = out.tx->GetHash(); @@ -738,7 +738,7 @@ void CoinControlDialog::updateView() map> mapCoins; model->listCoins(mapCoins); - BOOST_FOREACH (PAIRTYPE(QString, vector) coins, mapCoins) { + for (PAIRTYPE(QString, vector) coins : mapCoins) { CCoinControlWidgetItem* itemWalletAddress = new CCoinControlWidgetItem(); itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); QString sWalletAddress = coins.first; diff --git a/src/qt/masternodelist.cpp b/src/qt/masternodelist.cpp index c870d5608274b..62be6e43f7d73 100644 --- a/src/qt/masternodelist.cpp +++ b/src/qt/masternodelist.cpp @@ -90,7 +90,7 @@ void MasternodeList::StartAlias(std::string strAlias) std::string strStatusHtml; strStatusHtml += "
Alias: " + strAlias; - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { if (mne.getAlias() == strAlias) { std::string strError; CMasternodeBroadcast mnb; @@ -122,7 +122,7 @@ void MasternodeList::StartAll(std::string strCommand) int nCountFailed = 0; std::string strFailedHtml; - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { std::string strError; CMasternodeBroadcast mnb; @@ -210,7 +210,7 @@ void MasternodeList::updateMyNodeList(bool fForce) nTimeMyListUpdated = GetTime(); ui->tableWidgetMyMasternodes->setSortingEnabled(false); - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { int nIndex; if(!mne.castOutputIndex(nIndex)) continue; diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 0a6f38b93f85f..38e35c908e21a 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -76,7 +76,7 @@ class PeerTablePriv { TRY_LOCK(cs_main, lockMain); if (lockMain) { - BOOST_FOREACH (CNodeCombinedStats& stats, cachedNodeStats) + for (CNodeCombinedStats& stats : cachedNodeStats) stats.fNodeStateStatsAvailable = GetNodeStateStats(stats.nodeStats.nodeid, stats.nodeStateStats); } } diff --git a/src/qt/recentrequeststablemodel.cpp b/src/qt/recentrequeststablemodel.cpp index 881e5b335f285..ee410c4b0b807 100644 --- a/src/qt/recentrequeststablemodel.cpp +++ b/src/qt/recentrequeststablemodel.cpp @@ -21,7 +21,7 @@ RecentRequestsTableModel::RecentRequestsTableModel(CWallet* wallet, WalletModel* // Load entries from wallet std::vector vReceiveRequests; parent->loadReceiveRequests(vReceiveRequests); - BOOST_FOREACH (const std::string& request, vReceiveRequests) + for (const std::string& request : vReceiveRequests) addNewRequest(request); /* These columns must match the indices in the ColumnIndex enumeration */ diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 7c4b314c87168..79a1a2ac0e939 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -156,7 +156,7 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco // Coinbase // CAmount nUnmatured = 0; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) + for (const CTxOut& txout : wtx.vout) nUnmatured += wallet->GetCredit(txout, ISMINE_ALL); strHTML += "" + tr("Credit") + ": "; if (wtx.IsInMainChain()) @@ -171,13 +171,13 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, nNet) + "
"; } else { isminetype fAllFromMe = ISMINE_SPENDABLE; - BOOST_FOREACH (const CTxIn& txin, wtx.vin) { + for (const CTxIn& txin : wtx.vin) { isminetype mine = wallet->IsMine(txin); if (fAllFromMe > mine) fAllFromMe = mine; } isminetype fAllToMe = ISMINE_SPENDABLE; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) { + for (const CTxOut& txout : wtx.vout) { isminetype mine = wallet->IsMine(txout); if (fAllToMe > mine) fAllToMe = mine; } @@ -189,7 +189,7 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco // // Debit // - BOOST_FOREACH (const CTxOut& txout, wtx.vout) { + for (const CTxOut& txout : wtx.vout) { // Ignore change isminetype toSelf = wallet->IsMine(txout); if ((toSelf == ISMINE_SPENDABLE) && (fAllFromMe == ISMINE_SPENDABLE)) @@ -231,10 +231,10 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco // // Mixed debit transaction // - BOOST_FOREACH (const CTxIn& txin, wtx.vin) + for (const CTxIn& txin : wtx.vin) if (wallet->IsMine(txin)) strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "
"; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) + for (const CTxOut& txout : wtx.vout) if (wallet->IsMine(txout)) strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "
"; } @@ -281,10 +281,10 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco // if (fDebug) { strHTML += "

" + tr("Debug information") + "

"; - BOOST_FOREACH (const CTxIn& txin, wtx.vin) + for (const CTxIn& txin : wtx.vin) if (wallet->IsMine(txin)) strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "
"; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) + for (const CTxOut& txout : wtx.vout) if (wallet->IsMine(txout)) strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "
"; @@ -294,7 +294,7 @@ QString TransactionDesc::toHTML(CWallet* wallet, CWalletTx& wtx, TransactionReco strHTML += "
" + tr("Inputs") + ":"; strHTML += "
    "; - BOOST_FOREACH (const CTxIn& txin, wtx.vin) { + for (const CTxIn& txin : wtx.vin) { COutPoint prevout = txin.prevout; CCoins prev; diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index c91ee690e3670..52b05ef717137 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -152,7 +152,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet* // // Credit // - BOOST_FOREACH (const CTxOut& txout, wtx.vout) { + for (const CTxOut& txout : wtx.vout) { isminetype mine = wallet->IsMine(txout); if (mine) { TransactionRecord sub(hash, nTime); @@ -182,7 +182,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet* int nFromMe = 0; bool involvesWatchAddress = false; isminetype fAllFromMe = ISMINE_SPENDABLE; - BOOST_FOREACH (const CTxIn& txin, wtx.vin) { + for (const CTxIn& txin : wtx.vin) { if (wallet->IsMine(txin)) { fAllFromMeDenom = fAllFromMeDenom && wallet->IsDenominated(txin); nFromMe++; @@ -195,7 +195,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet* isminetype fAllToMe = ISMINE_SPENDABLE; bool fAllToMeDenom = true; int nToMe = 0; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) { + for (const CTxOut& txout : wtx.vout) { if (wallet->IsMine(txout)) { fAllToMeDenom = fAllToMeDenom && wallet->IsDenominatedAmount(txout.nValue); nToMe++; diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index c597bb732bf35..6f223182e5a2f 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -63,7 +63,7 @@ CAmount WalletModel::getBalance(const CCoinControl* coinControl) const CAmount nBalance = 0; std::vector vCoins; wallet->AvailableCoins(vCoins, true, coinControl); - BOOST_FOREACH (const COutput& out, vCoins) + for (const COutput& out : vCoins) if (out.fSpendable) nBalance += out.tx->vout[out.i].nValue; @@ -685,7 +685,7 @@ bool WalletModel::getPubKey(const CKeyID& address, CPubKey& vchPubKeyOut) const void WalletModel::getOutputs(const std::vector& vOutpoints, std::vector& vOutputs) { LOCK2(cs_main, wallet->cs_wallet); - BOOST_FOREACH (const COutPoint& outpoint, vOutpoints) { + for (const COutPoint& outpoint : vOutpoints) { if (!wallet->mapWallet.count(outpoint.hash)) continue; int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); if (nDepth < 0) continue; @@ -711,7 +711,7 @@ void WalletModel::listCoins(std::map >& mapCoins) wallet->ListLockedCoins(vLockedCoins); // add locked coins - BOOST_FOREACH (const COutPoint& outpoint, vLockedCoins) { + for (const COutPoint& outpoint : vLockedCoins) { if (!wallet->mapWallet.count(outpoint.hash)) continue; int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); if (nDepth < 0) continue; @@ -720,7 +720,7 @@ void WalletModel::listCoins(std::map >& mapCoins) vCoins.push_back(out); } - BOOST_FOREACH (const COutput& out, vCoins) { + for (const COutput& out : vCoins) { COutput cout = out; while (wallet->IsChange(cout.tx->vout[cout.i]) && cout.tx->vin.size() > 0 && wallet->IsMine(cout.tx->vin[0])) { @@ -769,8 +769,8 @@ void WalletModel::listZerocoinMints(std::set& setMints, bool fUnusedO void WalletModel::loadReceiveRequests(std::vector& vReceiveRequests) { LOCK(wallet->cs_wallet); - BOOST_FOREACH (const PAIRTYPE(CTxDestination, CAddressBookData) & item, wallet->mapAddressBook) - BOOST_FOREACH (const PAIRTYPE(std::string, std::string) & item2, item.second.destdata) + for (const PAIRTYPE(CTxDestination, CAddressBookData) & item : wallet->mapAddressBook) + for (const PAIRTYPE(std::string, std::string) & item2 : item.second.destdata) if (item2.first.size() > 2 && item2.first.substr(0, 2) == "rr") // receive request vReceiveRequests.push_back(item2.second); } diff --git a/src/rest.cpp b/src/rest.cpp index 9bc261b2c130d..8ab9dabbf6043 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -154,7 +154,7 @@ static bool rest_headers(HTTPRequest* req, } CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION); - BOOST_FOREACH(const CBlockIndex *pindex, headers) { + for (const CBlockIndex *pindex : headers) { ssHeader << pindex->GetBlockHeader(); } @@ -174,7 +174,7 @@ static bool rest_headers(HTTPRequest* req, } case RF_JSON: { UniValue jsonHeaders(UniValue::VARR); - BOOST_FOREACH(const CBlockIndex *pindex, headers) { + for (const CBlockIndex *pindex : headers) { jsonHeaders.push_back(blockheaderToJSON(pindex)); } string strJSON = jsonHeaders.write() + "\n"; @@ -560,7 +560,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart) objGetUTXOResponse.push_back(Pair("bitmap", bitmapStringRepresentation)); UniValue utxos(UniValue::VARR); - BOOST_FOREACH (const CCoin& coin, outs) { + for (const CCoin& coin : outs) { UniValue utxo(UniValue::VOBJ); utxo.push_back(Pair("txvers", (int32_t)coin.nTxVer)); utxo.push_back(Pair("height", (int32_t)coin.nHeight)); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index ce9a0a89b5deb..5bd6691eca1e7 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -111,7 +111,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); result.push_back(Pair("acc_checkpoint", block.nAccumulatorCheckpoint.GetHex())); UniValue txs(UniValue::VARR); - BOOST_FOREACH (const CTransaction& tx, block.vtx) { + for (const CTransaction& tx : block.vtx) { if (txDetails) { UniValue objTx(UniValue::VOBJ); TxToJSON(tx, uint256(0), objTx); @@ -432,7 +432,7 @@ UniValue mempoolToJSON(bool fVerbose = false) if (fVerbose) { LOCK(mempool.cs); UniValue o(UniValue::VOBJ); - BOOST_FOREACH (const PAIRTYPE(uint256, CTxMemPoolEntry) & entry, mempool.mapTx) { + for (const PAIRTYPE(uint256, CTxMemPoolEntry) & entry : mempool.mapTx) { const uint256& hash = entry.first; const CTxMemPoolEntry& e = entry.second; UniValue info(UniValue::VOBJ); @@ -444,13 +444,13 @@ UniValue mempoolToJSON(bool fVerbose = false) info.push_back(Pair("currentpriority", e.GetPriority(chainActive.Height()))); const CTransaction& tx = e.GetTx(); set setDepends; - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { if (mempool.exists(txin.prevout.hash)) setDepends.insert(txin.prevout.hash.ToString()); } UniValue depends(UniValue::VARR); - BOOST_FOREACH(const string& dep, setDepends) { + for (const string& dep : setDepends) { depends.push_back(dep); } @@ -463,7 +463,7 @@ UniValue mempoolToJSON(bool fVerbose = false) mempool.queryHashes(vtxid); UniValue a(UniValue::VARR); - BOOST_FOREACH (const uint256& hash, vtxid) + for (const uint256& hash : vtxid) a.push_back(hash.ToString()); return a; @@ -956,9 +956,9 @@ UniValue getchaintips(const UniValue& params, bool fHelp) known blocks, and successively remove blocks that appear as pprev of another block. */ std::set setTips; - BOOST_FOREACH (const PAIRTYPE(const uint256, CBlockIndex*) & item, mapBlockIndex) + for (const PAIRTYPE(const uint256, CBlockIndex*) & item : mapBlockIndex) setTips.insert(item.second); - BOOST_FOREACH (const PAIRTYPE(const uint256, CBlockIndex*) & item, mapBlockIndex) { + for (const PAIRTYPE(const uint256, CBlockIndex*) & item : mapBlockIndex) { const CBlockIndex* pprev = item.second->pprev; if (pprev) setTips.erase(pprev); @@ -969,7 +969,7 @@ UniValue getchaintips(const UniValue& params, bool fHelp) /* Construct the output array. */ UniValue res(UniValue::VARR); - BOOST_FOREACH (const CBlockIndex* block, setTips) { + for (const CBlockIndex* block : setTips) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("height", block->nHeight)); obj.push_back(Pair("hash", block->phashBlock->GetHex())); diff --git a/src/rpc/budget.cpp b/src/rpc/budget.cpp index 6a799c28d8d3a..a59815936d52f 100644 --- a/src/rpc/budget.cpp +++ b/src/rpc/budget.cpp @@ -353,7 +353,7 @@ UniValue mnbudgetvote(const UniValue& params, bool fHelp) } if (strCommand == "many") { - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { std::string errorMessage; std::vector vchMasterNodeSignature; std::string strMasterNodeSignMessage; @@ -424,7 +424,7 @@ UniValue mnbudgetvote(const UniValue& params, bool fHelp) std::vector mnEntries; mnEntries = masternodeConfig.getEntries(); - BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { if( strAlias != mne.getAlias()) continue; @@ -610,7 +610,7 @@ UniValue getbudgetprojection(const UniValue& params, bool fHelp) CAmount nTotalAllotted = 0; std::vector winningProps = budget.GetBudget(); - BOOST_FOREACH (CBudgetProposal* pbudgetProposal, winningProps) { + for (CBudgetProposal* pbudgetProposal : winningProps) { nTotalAllotted += pbudgetProposal->GetAllotted(); CTxDestination address1; @@ -681,7 +681,7 @@ UniValue getbudgetinfo(const UniValue& params, bool fHelp) } std::vector winningProps = budget.GetAllProposals(); - BOOST_FOREACH (CBudgetProposal* pbudgetProposal, winningProps) { + for (CBudgetProposal* pbudgetProposal : winningProps) { if (strShow == "valid" && !pbudgetProposal->fValid) continue; UniValue bObj(UniValue::VOBJ); @@ -787,7 +787,7 @@ UniValue mnfinalbudget(const UniValue& params, bool fHelp) UniValue resultsObj(UniValue::VOBJ); - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { std::string errorMessage; std::vector vchMasterNodeSignature; std::string strMasterNodeSignMessage; @@ -885,7 +885,7 @@ UniValue mnfinalbudget(const UniValue& params, bool fHelp) UniValue resultObj(UniValue::VOBJ); std::vector winningFbs = budget.GetFinalizedBudgets(); - BOOST_FOREACH (CFinalizedBudget* finalizedBudget, winningFbs) { + for (CFinalizedBudget* finalizedBudget : winningFbs) { UniValue bObj(UniValue::VOBJ); bObj.push_back(Pair("FeeTX", finalizedBudget->nFeeTXHash.ToString())); bObj.push_back(Pair("Hash", finalizedBudget->GetHash().ToString())); diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index 8fd3cdb5915bf..3f05d651dc19d 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -88,7 +88,7 @@ UniValue listmasternodes(const UniValue& params, bool fHelp) nHeight = pindex->nHeight; } std::vector > vMasternodeRanks = mnodeman.GetMasternodeRanks(nHeight); - BOOST_FOREACH (PAIRTYPE(int, CMasternode) & s, vMasternodeRanks) { + for (PAIRTYPE(int, CMasternode) & s : vMasternodeRanks) { UniValue obj(UniValue::VOBJ); std::string strVin = s.second.vin.prevout.ToStringShort(); std::string strTxHash = s.second.vin.prevout.hash.ToString(); @@ -330,7 +330,7 @@ UniValue startmasternode (const UniValue& params, bool fHelp) UniValue resultsObj(UniValue::VARR); - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { std::string errorMessage; int nIndex; if(!mne.castOutputIndex(nIndex)) @@ -381,7 +381,7 @@ UniValue startmasternode (const UniValue& params, bool fHelp) UniValue statusObj(UniValue::VOBJ); statusObj.push_back(Pair("alias", alias)); - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { if (mne.getAlias() == alias) { found = true; std::string errorMessage; @@ -465,7 +465,7 @@ UniValue getmasternodeoutputs (const UniValue& params, bool fHelp) vector possibleCoins = activeMasternode.SelectCoinsMasternode(); UniValue ret(UniValue::VARR); - BOOST_FOREACH (COutput& out, possibleCoins) { + for (COutput& out : possibleCoins) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txhash", out.tx->GetHash().ToString())); obj.push_back(Pair("outputidx", out.i)); @@ -510,7 +510,7 @@ UniValue listmasternodeconf (const UniValue& params, bool fHelp) UniValue ret(UniValue::VARR); - BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { int nIndex; if(!mne.castOutputIndex(nIndex)) continue; @@ -646,7 +646,7 @@ UniValue getmasternodewinners (const UniValue& params, bool fHelp) UniValue winner(UniValue::VARR); boost::char_separator sep(","); boost::tokenizer< boost::char_separator > tokens(strPayment, sep); - BOOST_FOREACH (const string& t, tokens) { + for (const string& t : tokens) { UniValue addr(UniValue::VOBJ); std::size_t pos = t.find(":"); std::string strAddress = t.substr(0,pos); @@ -711,7 +711,7 @@ UniValue getmasternodescores (const UniValue& params, bool fHelp) for (int nHeight = chainActive.Tip()->nHeight - nLast; nHeight < chainActive.Tip()->nHeight + 20; nHeight++) { uint256 nHigh = 0; CMasternode* pBestMasternode = NULL; - BOOST_FOREACH (CMasternode& mn, vMasternodes) { + for (CMasternode& mn : vMasternodes) { uint256 n = mn.CalculateScore(1, nHeight - 100); if (n > nHigh) { nHigh = n; @@ -795,7 +795,7 @@ UniValue createmasternodebroadcast(const UniValue& params, bool fHelp) UniValue statusObj(UniValue::VOBJ); statusObj.push_back(Pair("alias", alias)); - BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { if(mne.getAlias() == alias) { found = true; std::string errorMessage; @@ -838,7 +838,7 @@ UniValue createmasternodebroadcast(const UniValue& params, bool fHelp) UniValue resultsObj(UniValue::VARR); - BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { + for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) { std::string errorMessage; CTxIn vin = CTxIn(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str()))); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 325d11443c5b3..609acb0efe13f 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -545,7 +545,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) UniValue transactions(UniValue::VARR); map setTxIndex; int i = 0; - BOOST_FOREACH (CTransaction& tx, pblock->vtx) { + for (CTransaction& tx : pblock->vtx) { uint256 txHash = tx.GetHash(); setTxIndex[txHash] = i++; @@ -559,7 +559,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) entry.push_back(Pair("hash", txHash.GetHex())); UniValue deps(UniValue::VARR); - BOOST_FOREACH (const CTxIn& in, tx.vin) { + for (const CTxIn& in : tx.vin) { if (setTxIndex.count(in.prevout.hash)) deps.push_back(setTxIndex[in.prevout.hash]); } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index fc732ea24f73d..a37eda7314dd7 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -277,7 +277,7 @@ class DescribeAddressVisitor : public boost::static_visitor obj.push_back(Pair("script", GetTxnOutputType(whichType))); obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); UniValue a(UniValue::VARR); - BOOST_FOREACH (const CTxDestination& addr, addresses) + for (const CTxDestination& addr : addresses) a.push_back(CBitcoinAddress(addr).ToString()); obj.push_back(Pair("addresses", a)); if (whichType == TX_MULTISIG) diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index fc3938471c254..bf879f1fb2403 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -56,7 +56,7 @@ UniValue ping(const UniValue& params, bool fHelp) // Request that each node send a ping during next message processing pass LOCK2(cs_main, cs_vNodes); - BOOST_FOREACH (CNode* pNode, vNodes) { + for (CNode* pNode : vNodes) { pNode->fPingQueued = true; } @@ -69,7 +69,7 @@ static void CopyNodeStats(std::vector& vstats) LOCK(cs_vNodes); vstats.reserve(vNodes.size()); - BOOST_FOREACH (CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { CNodeStats stats; pnode->copyStats(stats); vstats.push_back(stats); @@ -123,7 +123,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp) UniValue ret(UniValue::VARR); - BOOST_FOREACH (const CNodeStats& stats, vstats) { + for (const CNodeStats& stats : vstats) { UniValue obj(UniValue::VOBJ); CNodeStateStats statestats; bool fStateStats = GetNodeStateStats(stats.nodeid, statestats); @@ -153,7 +153,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("synced_headers", statestats.nSyncHeight)); obj.push_back(Pair("synced_blocks", statestats.nCommonHeight)); UniValue heights(UniValue::VARR); - BOOST_FOREACH (int height, statestats.vHeightInFlight) { + for (int height : statestats.vHeightInFlight) { heights.push_back(height); } obj.push_back(Pair("inflight", heights)); @@ -274,12 +274,12 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) list laddedNodes(0); if (params.size() == 1) { LOCK(cs_vAddedNodes); - BOOST_FOREACH (string& strAddNode, vAddedNodes) + for (string& strAddNode : vAddedNodes) laddedNodes.push_back(strAddNode); } else { string strNode = params[1].get_str(); LOCK(cs_vAddedNodes); - BOOST_FOREACH (string& strAddNode, vAddedNodes) + for (string& strAddNode : vAddedNodes) if (strAddNode == strNode) { laddedNodes.push_back(strAddNode); break; @@ -290,7 +290,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) UniValue ret(UniValue::VARR); if (!fDns) { - BOOST_FOREACH (string& strAddNode, laddedNodes) { + for (string& strAddNode : laddedNodes) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("addednode", strAddNode)); ret.push_back(obj); @@ -299,7 +299,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) } list > > laddedAddreses(0); - BOOST_FOREACH (string& strAddNode, laddedNodes) { + for (string& strAddNode : laddedNodes) { vector vservNode(0); if (Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0)) laddedAddreses.push_back(make_pair(strAddNode, vservNode)); @@ -319,11 +319,11 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp) UniValue addresses(UniValue::VARR); bool fConnected = false; - BOOST_FOREACH (CService& addrNode, it->second) { + for (CService& addrNode : it->second) { bool fFound = false; UniValue node(UniValue::VOBJ); node.push_back(Pair("address", addrNode.ToString())); - BOOST_FOREACH (CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->addr == addrNode) { fFound = true; fConnected = true; @@ -439,7 +439,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp) UniValue localAddresses(UniValue::VARR); { LOCK(cs_mapLocalHost); - BOOST_FOREACH (const PAIRTYPE(CNetAddr, LocalServiceInfo) & item, mapLocalHost) { + for (const PAIRTYPE(CNetAddr, LocalServiceInfo) & item : mapLocalHost) { UniValue rec(UniValue::VOBJ); rec.push_back(Pair("address", item.first.ToString())); rec.push_back(Pair("port", item.second.nPort)); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 69dc2c77ace86..eab514f9086c4 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -55,7 +55,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fInclud out.push_back(Pair("type", GetTxnOutputType(type))); UniValue a(UniValue::VARR); - BOOST_FOREACH (const CTxDestination& addr, addresses) + for (const CTxDestination& addr : addresses) a.push_back(CBitcoinAddress(addr).ToString()); out.push_back(Pair("addresses", a)); } @@ -281,7 +281,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, false, NULL, false, ALL_COINS, false, nWatchonlyConfig); - BOOST_FOREACH (const COutput& out, vecOutputs) { + for (const COutput& out : vecOutputs) { if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) continue; @@ -407,7 +407,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) set setAddress; vector addrList = sendTo.getKeys(); - BOOST_FOREACH(const string& name_, addrList) { + for (const string& name_ : addrList) { CBitcoinAddress address(name_); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid PIVX address: ")+name_); @@ -651,7 +651,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp) CCoinsViewMemPool viewMempool(&viewChain, mempool); view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view - BOOST_FOREACH (const CTxIn& txin, mergedTx.vin) { + for (const CTxIn& txin : mergedTx.vin) { const uint256& prevHash = txin.prevout.hash; CCoins coins; view.AccessCoins(prevHash); // this is certainly allowed to fail @@ -777,7 +777,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp) SignSignature(keystore, prevPubKey, mergedTx, i, nHashType); // ... and merge in other signatures: - BOOST_FOREACH (const CMutableTransaction& txv, txVariants) { + for (const CMutableTransaction& txv : txVariants) { txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig); } ScriptError serror = SCRIPT_ERR_OK; diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 2ac9909bcb43f..d6b33cd887db9 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -75,7 +75,7 @@ void RPCTypeCheck(const UniValue& params, bool fAllowNull) { unsigned int i = 0; - BOOST_FOREACH(UniValue::VType t, typesExpected) { + for (UniValue::VType t : typesExpected) { if (params.size() <= i) break; @@ -93,7 +93,7 @@ void RPCTypeCheckObj(const UniValue& o, const map& typesExpected, bool fAllowNull) { - BOOST_FOREACH(const PAIRTYPE(string, UniValue::VType)& t, typesExpected) { + for (const PAIRTYPE(string, UniValue::VType)& t : typesExpected) { const UniValue& v = find_value(o, t.first); if (!fAllowNull && v.isNull()) throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first)); @@ -200,7 +200,7 @@ string CRPCTable::help(string strCommand) const vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second)); sort(vCommands.begin(), vCommands.end()); - BOOST_FOREACH (const PAIRTYPE(string, const CRPCCommand*) & command, vCommands) { + for (const PAIRTYPE(string, const CRPCCommand*) & command : vCommands) { const CRPCCommand* pcmd = command.second; string strMethod = pcmd->name; // We already filter duplicates, but these deprecated screw up the sort order diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 0e71ff2ea90d2..22b454c81d199 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -158,7 +158,7 @@ bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CMutab static CScript PushAll(const vector& values) { CScript result; - BOOST_FOREACH(const valtype& v, values) + for (const valtype& v : values) result << v; return result; } @@ -169,12 +169,12 @@ static CScript CombineMultisig(const CScript& scriptPubKey, const CTransaction& { // Combine all the signatures we've got: set allsigs; - BOOST_FOREACH(const valtype& v, sigs1) + for (const valtype& v : sigs1) { if (!v.empty()) allsigs.insert(v); } - BOOST_FOREACH(const valtype& v, sigs2) + for (const valtype& v : sigs2) { if (!v.empty()) allsigs.insert(v); @@ -185,7 +185,7 @@ static CScript CombineMultisig(const CScript& scriptPubKey, const CTransaction& unsigned int nSigsRequired = vSolutions.front()[0]; unsigned int nPubKeys = vSolutions.size()-2; map sigs; - BOOST_FOREACH(const valtype& sig, allsigs) + for (const valtype& sig : allsigs) { for (unsigned int i = 0; i < nPubKeys; i++) { diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 325c1f2985269..0b0ebfcddf0c7 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -86,7 +86,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector& keys) CScript script; script << CScript::EncodeOP_N(nRequired); - BOOST_FOREACH(const CPubKey& key, keys) + for (const CPubKey& key : keys) script << ToByteVector(key); script << CScript::EncodeOP_N(keys.size()) << OP_CHECKMULTISIG; return script; diff --git a/src/swifttx.cpp b/src/swifttx.cpp index de1550828a4c8..8649721235f0a 100644 --- a/src/swifttx.cpp +++ b/src/swifttx.cpp @@ -59,7 +59,7 @@ void ProcessMessageSwiftTX(CNode* pfrom, std::string& strCommand, CDataStream& v return; } - BOOST_FOREACH (const CTxOut o, tx.vout) { + for (const CTxOut o : tx.vout) { // IX supports normal scripts and unspendable scripts (used in DS collateral and Budget collateral). // TODO: Look into other script types that are normal and can be included if (!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()) { @@ -104,7 +104,7 @@ void ProcessMessageSwiftTX(CNode* pfrom, std::string& strCommand, CDataStream& v pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str(), tx.GetHash().ToString().c_str()); - BOOST_FOREACH (const CTxIn& in, tx.vin) { + for (const CTxIn& in : tx.vin) { if (!mapLockedInputs.count(in.prevout)) { mapLockedInputs.insert(make_pair(in.prevout, tx.GetHash())); } @@ -183,10 +183,10 @@ bool IsIXTXValid(const CTransaction& txCollateral) CAmount nValueOut = 0; bool missingTx = false; - BOOST_FOREACH (const CTxOut o, txCollateral.vout) + for (const CTxOut o : txCollateral.vout) nValueOut += o.nValue; - BOOST_FOREACH (const CTxIn i, txCollateral.vin) { + for (const CTxIn i : txCollateral.vin) { CTransaction tx2; uint256 hash; if (GetTransaction(i.prevout.hash, tx2, hash, true)) { @@ -368,7 +368,7 @@ bool ProcessConsensusVote(CNode* pnode, CConsensusVote& ctx) #endif if (mapTxLockReq.count(ctx.txHash)) { - BOOST_FOREACH (const CTxIn& in, tx.vin) { + for (const CTxIn& in : tx.vin) { if (!mapLockedInputs.count(in.prevout)) { mapLockedInputs.insert(make_pair(in.prevout, ctx.txHash)); } @@ -400,7 +400,7 @@ bool CheckForConflictingLocks(CTransaction& tx) Blocks could have been rejected during this time, which is OK. After they cancel out, the client will rescan the blocks and find they're acceptable and then take the chain with the most work. */ - BOOST_FOREACH (const CTxIn& in, tx.vin) { + for (const CTxIn& in : tx.vin) { if (mapLockedInputs.count(in.prevout)) { if (mapLockedInputs[in.prevout] != tx.GetHash()) { LogPrintf("SwiftX::CheckForConflictingLocks - found two complete conflicting locks - removing both. %s %s", tx.GetHash().ToString().c_str(), mapLockedInputs[in.prevout].ToString().c_str()); @@ -442,13 +442,13 @@ void CleanTransactionLocksList() if (mapTxLockReq.count(it->second.txHash)) { CTransaction& tx = mapTxLockReq[it->second.txHash]; - BOOST_FOREACH (const CTxIn& in, tx.vin) + for (const CTxIn& in : tx.vin) mapLockedInputs.erase(in.prevout); mapTxLockReq.erase(it->second.txHash); mapTxLockReqRejected.erase(it->second.txHash); - BOOST_FOREACH (CConsensusVote& v, it->second.vecConsensusVotes) + for (CConsensusVote& v : it->second.vecConsensusVotes) mapTxLockVote.erase(v.GetHash()); } @@ -528,7 +528,7 @@ bool CConsensusVote::Sign() bool CTransactionLock::SignaturesValid() { - BOOST_FOREACH (CConsensusVote vote, vecConsensusVotes) { + for (CConsensusVote vote : vecConsensusVotes) { int n = mnodeman.GetMasternodeRank(vote.vinMasternode, vote.nBlockHeight, MIN_SWIFTTX_PROTO_VERSION); if (n == -1) { @@ -565,7 +565,7 @@ int CTransactionLock::CountSignatures() if (nBlockHeight == 0) return -1; int n = 0; - BOOST_FOREACH (CConsensusVote v, vecConsensusVotes) { + for (CConsensusVote v : vecConsensusVotes) { if (v.nBlockHeight == nBlockHeight) { n++; } diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp index 579da3c1b6287..e18bbb834bd94 100644 --- a/src/test/accounting_tests.cpp +++ b/src/test/accounting_tests.cpp @@ -23,7 +23,7 @@ GetResults(CWalletDB& walletdb, std::map& results) results.clear(); BOOST_CHECK(walletdb.ReorderTransactions(pwalletMain) == DB_LOAD_OK); walletdb.ListAccountCreditDebit("", aes); - BOOST_FOREACH(CAccountingEntry& ae, aes) + for (CAccountingEntry& ae : aes) { results[ae.nOrderPos] = ae; } diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index 4869ba52acceb..4b3c04f87fee0 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(AlertApplies) { SetMockTime(11); - BOOST_FOREACH(const CAlert& alert, alerts) + for (const CAlert& alert : alerts) { BOOST_CHECK(alert.CheckSignature()); } @@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(AlertNotify) mapArgs["-alertnotify"] = std::string("echo %s >> ") + temp.string(); - BOOST_FOREACH(CAlert alert, alerts) + for (CAlert alert : alerts) alert.ProcessAlert(false); std::vector r = read_lines(temp); diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp index 9cf07fc38cc76..465538185b0f6 100644 --- a/src/test/bip32_tests.cpp +++ b/src/test/bip32_tests.cpp @@ -82,7 +82,7 @@ void RunTest(const TestVector &test) { CExtPubKey pubkey; key.SetMaster(&seed[0], seed.size()); pubkey = key.Neuter(); - BOOST_FOREACH(const TestDerivation &derive, test.vDerive) { + for (const TestDerivation &derive : test.vDerive) { unsigned char data[74]; key.Encode(data); pubkey.Encode(data); diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp index 560404284af44..b5c4eec9bc354 100644 --- a/src/test/getarg_tests.cpp +++ b/src/test/getarg_tests.cpp @@ -25,7 +25,7 @@ static void ResetArgs(const std::string& strArg) // Convert to char*: std::vector vecChar; - BOOST_FOREACH(std::string& s, vecArg) + for (std::string& s : vecArg) vecChar.push_back(s.c_str()); ParseParameters(vecChar.size(), &vecChar[0]); diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index a088d7d0970e5..47980eb6c1633 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -259,7 +259,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) SetMockTime(0); mempool.clear(); - BOOST_FOREACH(CTransaction *tx, txFirst) + for (CTransaction *tx : txFirst) delete tx; Checkpoints::fEnabled = true; diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index 9caab9ddd9f16..1fcb689f588cb 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -33,7 +33,7 @@ sign_multisig(CScript scriptPubKey, vector keys, CTransaction transaction, CScript result; result << OP_0; // CHECKMULTISIG bug workaround - BOOST_FOREACH(const CKey &key, keys) + for (const CKey &key : keys) { vector vchSig; BOOST_CHECK(key.Sign(hash, vchSig)); diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index ce24f601aefa5..ba22d805d5954 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -583,7 +583,7 @@ BOOST_AUTO_TEST_CASE(script_build) std::string strGood; std::string strBad; - BOOST_FOREACH(TestBuilder& test, good) { + for (TestBuilder& test : good) { test.Test(true); std::string str = test.GetJSON().write(); #ifndef UPDATE_JSON_TESTS @@ -593,7 +593,7 @@ BOOST_AUTO_TEST_CASE(script_build) #endif strGood += str + ",\n"; } - BOOST_FOREACH(TestBuilder& test, bad) { + for (TestBuilder& test : bad) { test.Test(false); std::string str = test.GetJSON().write(); #ifndef UPDATE_JSON_TESTS @@ -713,7 +713,7 @@ sign_multisig(CScript scriptPubKey, std::vector keys, CTransaction transac // and vice-versa) // result << OP_0; - BOOST_FOREACH(const CKey &key, keys) + for (const CKey &key : keys) { vector vchSig; BOOST_CHECK(key.Sign(hash, vchSig)); diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 4c27e1e2800fd..7706c1ffc1182 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -53,7 +53,7 @@ unsigned int ParseScriptFlags(string strFlags) vector words; split(words, strFlags, is_any_of(",")); - BOOST_FOREACH(string word, words) + for (string word : words) { if (!mapFlagNames.count(word)) BOOST_ERROR("Bad test: unknown verification flag '" << word << "'"); diff --git a/src/test/zerocoin_implementation_tests.cpp b/src/test/zerocoin_implementation_tests.cpp index 0390f02093e61..82091d386aca1 100644 --- a/src/test/zerocoin_implementation_tests.cpp +++ b/src/test/zerocoin_implementation_tests.cpp @@ -174,7 +174,7 @@ bool CheckZerocoinSpendNoDB(const CTransaction tx, string& strError) set serials; list vSpends; CAmount nTotalRedeemed = 0; - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { //only check txin that is a zcspend if (!txin.IsZerocoinSpend()) diff --git a/src/timedata.cpp b/src/timedata.cpp index 5f7d3813a96f1..ea9ba95996118 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -84,7 +84,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) if (!fDone) { // If nobody has a time different than ours but within 5 minutes of ours, give a warning bool fMatch = false; - BOOST_FOREACH (int64_t nOffset, vSorted) + for (int64_t nOffset : vSorted) if (nOffset != 0 && abs64(nOffset) < 5 * 60) fMatch = true; @@ -98,7 +98,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) } } if (fDebug) { - BOOST_FOREACH (int64_t n, vSorted) + for (int64_t n : vSorted) LogPrintf("%+d ", n); LogPrintf("| "); } diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 48787fd1e0346..70b1bc312f937 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -489,7 +489,7 @@ void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlRe { if (reply.code == 250) { LogPrint("tor", "tor: ADD_ONION successful\n"); - BOOST_FOREACH(const std::string &s, reply.lines) { + for (const std::string &s : reply.lines) { std::map m = ParseTorReplyMapping(s); std::map::iterator i; if ((i = m.find("ServiceID")) != m.end()) @@ -620,7 +620,7 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro * 250-AUTH METHODS=NULL * 250-AUTH METHODS=HASHEDPASSWORD */ - BOOST_FOREACH(const std::string &s, reply.lines) { + for (const std::string &s : reply.lines) { std::pair l = SplitTorReplyLine(s); if (l.first == "AUTH") { std::map m = ParseTorReplyMapping(l.second); @@ -637,7 +637,7 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro } } } - BOOST_FOREACH(const std::string &s, methods) { + for (const std::string &s : methods) { LogPrint("tor", "tor: Supported authentication method: %s\n", s); } // Prefer NULL, otherwise SAFECOOKIE. If a password is provided, use HASHEDPASSWORD diff --git a/src/txmempool.cpp b/src/txmempool.cpp index f9a36c12ba083..08188172c7936 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -75,14 +75,14 @@ class CBlockAverage size_t FeeSamples() const { return feeSamples.size(); } size_t GetFeeSamples(std::vector& insertInto) const { - BOOST_FOREACH (const CFeeRate& f, feeSamples) + for (const CFeeRate& f : feeSamples) insertInto.push_back(f); return feeSamples.size(); } size_t PrioritySamples() const { return prioritySamples.size(); } size_t GetPrioritySamples(std::vector& insertInto) const { - BOOST_FOREACH (double d, prioritySamples) + for (double d : prioritySamples) insertInto.push_back(d); return prioritySamples.size(); } @@ -101,7 +101,7 @@ class CBlockAverage } static bool AreSane(const std::vector& vecFee, const CFeeRate& minRelayFee) { - BOOST_FOREACH (CFeeRate fee, vecFee) { + for (CFeeRate fee : vecFee) { if (!AreSane(fee, minRelayFee)) return false; } @@ -113,7 +113,7 @@ class CBlockAverage } static bool AreSane(const std::vector vecPriority) { - BOOST_FOREACH (double priority, vecPriority) { + for (double priority : vecPriority) { if (!AreSane(priority)) return false; } @@ -212,7 +212,7 @@ class CMinerPolicyEstimator // to confirm. std::vector > entriesByConfirmations; entriesByConfirmations.resize(history.size()); - BOOST_FOREACH (const CTxMemPoolEntry& entry, entries) { + for (const CTxMemPoolEntry& entry : entries) { // How many blocks did it take for miners to include this transaction? int delta = nBlockHeight - entry.GetHeight(); if (delta <= 0) { @@ -232,7 +232,7 @@ class CMinerPolicyEstimator std::random_shuffle(e.begin(), e.end()); e.resize(10); } - BOOST_FOREACH (const CTxMemPoolEntry* entry, e) { + for (const CTxMemPoolEntry* entry : e) { // Fees are stored and reported as BTC-per-kb: CFeeRate feeRate(entry->GetFee(), entry->GetTxSize()); double dPriority = entry->GetPriority(entry->GetHeight()); // Want priority when it went IN @@ -324,7 +324,7 @@ class CMinerPolicyEstimator { fileout << nBestSeenHeight; fileout << history.size(); - BOOST_FOREACH (const CBlockAverage& entry, history) { + for (const CBlockAverage& entry : history) { entry.Write(fileout); } } @@ -455,7 +455,7 @@ void CTxMemPool::remove(const CTransaction& origTx, std::list& rem txToRemove.push_back(it->second.ptx->GetHash()); } } - BOOST_FOREACH (const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) mapNextTx.erase(txin.prevout); removed.push_back(tx); @@ -473,7 +473,7 @@ void CTxMemPool::removeCoinbaseSpends(const CCoinsViewCache* pcoins, unsigned in list transactionsToRemove; for (std::map::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { const CTransaction& tx = it->second.GetTx(); - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { std::map::const_iterator it2 = mapTx.find(txin.prevout.hash); if (it2 != mapTx.end()) continue; @@ -485,7 +485,7 @@ void CTxMemPool::removeCoinbaseSpends(const CCoinsViewCache* pcoins, unsigned in } } } - BOOST_FOREACH (const CTransaction& tx, transactionsToRemove) { + for (const CTransaction& tx : transactionsToRemove) { list removed; remove(tx, removed, true); } @@ -496,7 +496,7 @@ void CTxMemPool::removeConflicts(const CTransaction& tx, std::list // Remove transactions which depend on inputs of tx, recursively list result; LOCK(cs); - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { std::map::iterator it = mapNextTx.find(txin.prevout); if (it != mapNextTx.end()) { const CTransaction& txConflict = *it->second.ptx; @@ -514,13 +514,13 @@ void CTxMemPool::removeForBlock(const std::vector& vtx, unsigned i { LOCK(cs); std::vector entries; - BOOST_FOREACH (const CTransaction& tx, vtx) { + for (const CTransaction& tx : vtx) { uint256 hash = tx.GetHash(); if (mapTx.count(hash)) entries.push_back(mapTx[hash]); } minerPolicyEstimator->seenBlock(entries, nBlockHeight, minRelayFee); - BOOST_FOREACH (const CTransaction& tx, vtx) { + for (const CTransaction& tx : vtx) { std::list dummy; remove(tx, dummy, false); removeConflicts(tx, conflicts); @@ -556,7 +556,7 @@ void CTxMemPool::check(const CCoinsViewCache* pcoins) const checkTotal += it->second.GetTxSize(); const CTransaction& tx = it->second.GetTx(); bool fDependsWait = false; - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { // Check that every mempool transaction's inputs refer to available coins, or other mempool tx's. std::map::const_iterator it2 = mapTx.find(txin.prevout.hash); if (it2 != mapTx.end()) { diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index a54c3e7514024..0cb3a3d71b83f 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -53,7 +53,7 @@ int64_t static DecodeDumpTime(const std::string& str) std::string static EncodeDumpString(const std::string& str) { std::stringstream ret; - BOOST_FOREACH (unsigned char c, str) { + for (unsigned char c : str) { if (c <= 32 || c >= 128 || c == '%') { ret << '%' << HexStr(&c, &c + 1); } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fbd22d46d5706..50a8d3ce0fac1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -63,12 +63,12 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) uint256 hash = wtx.GetHash(); entry.push_back(Pair("txid", hash.GetHex())); UniValue conflicts(UniValue::VARR); - BOOST_FOREACH (const uint256& conflict, wtx.GetConflicts()) + for (const uint256& conflict : wtx.GetConflicts()) conflicts.push_back(conflict.GetHex()); entry.push_back(Pair("walletconflicts", conflicts)); entry.push_back(Pair("time", wtx.GetTxTime())); entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived)); - BOOST_FOREACH (const PAIRTYPE(string, string) & item, wtx.mapValue) + for (const PAIRTYPE(string, string) & item : wtx.mapValue) entry.push_back(Pair(item.first, item.second)); } @@ -137,7 +137,7 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew = false) it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid(); ++it) { const CWalletTx& wtx = (*it).second; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) + for (const CTxOut& txout : wtx.vout) if (txout.scriptPubKey == scriptPubKey) bKeyUsed = true; } @@ -312,7 +312,7 @@ UniValue getaddressesbyaccount(const UniValue& params, bool fHelp) // Find all addresses that have the given account UniValue ret(UniValue::VARR); - BOOST_FOREACH (const PAIRTYPE(CBitcoinAddress, CAddressBookData) & item, pwalletMain->mapAddressBook) { + for (const PAIRTYPE(CBitcoinAddress, CAddressBookData) & item : pwalletMain->mapAddressBook) { const CBitcoinAddress& address = item.first; const string& strName = item.second.name; if (strName == strAccount) @@ -478,9 +478,9 @@ UniValue listaddressgroupings(const UniValue& params, bool fHelp) UniValue jsonGroupings(UniValue::VARR); map balances = pwalletMain->GetAddressBalances(); - BOOST_FOREACH (set grouping, pwalletMain->GetAddressGroupings()) { + for (set grouping : pwalletMain->GetAddressGroupings()) { UniValue jsonGrouping(UniValue::VARR); - BOOST_FOREACH (CTxDestination address, grouping) { + for (CTxDestination address : grouping) { UniValue addressInfo(UniValue::VARR); addressInfo.push_back(CBitcoinAddress(address).ToString()); addressInfo.push_back(ValueFromAmount(balances[address])); @@ -596,7 +596,7 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) if (wtx.IsCoinBase() || !IsFinalTx(wtx)) continue; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) + for (const CTxOut& txout : wtx.vout) if (txout.scriptPubKey == scriptPubKey) if (wtx.GetDepthInMainChain() >= nMinDepth) nAmount += txout.nValue; @@ -648,7 +648,7 @@ UniValue getreceivedbyaccount(const UniValue& params, bool fHelp) if (wtx.IsCoinBase() || !IsFinalTx(wtx)) continue; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) { + for (const CTxOut& txout : wtx.vout) { CTxDestination address; if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwalletMain, address) && setAddress.count(address)) if (wtx.GetDepthInMainChain() >= nMinDepth) @@ -750,10 +750,10 @@ UniValue getbalance(const UniValue& params, bool fHelp) list listSent; wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); if (wtx.GetDepthInMainChain() >= nMinDepth) { - BOOST_FOREACH (const COutputEntry& r, listReceived) + for (const COutputEntry& r : listReceived) nBalance += r.amount; } - BOOST_FOREACH (const COutputEntry& s, listSent) + for (const COutputEntry& s : listSent) nBalance -= s.amount; nBalance -= allFee; } @@ -960,7 +960,7 @@ UniValue sendmany(const UniValue& params, bool fHelp) CAmount totalAmount = 0; vector keys = sendTo.getKeys(); - BOOST_FOREACH(const string& name_, keys) { + for (const string& name_ : keys) { CBitcoinAddress address(name_); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid PIVX address: ")+name_); @@ -1087,7 +1087,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) if (nDepth < nMinDepth) continue; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) { + for (const CTxOut& txout : wtx.vout) { CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address)) continue; @@ -1109,7 +1109,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) // Reply UniValue ret(UniValue::VARR); map mapAccountTally; - BOOST_FOREACH (const PAIRTYPE(CBitcoinAddress, CAddressBookData) & item, pwalletMain->mapAddressBook) { + for (const PAIRTYPE(CBitcoinAddress, CAddressBookData) & item : pwalletMain->mapAddressBook) { const CBitcoinAddress& address = item.first; const string& strAccount = item.second.name; map::iterator it = mapTally.find(address); @@ -1144,7 +1144,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) obj.push_back(Pair("bcconfirmations", (nBCConf == std::numeric_limits::max() ? 0 : nBCConf))); UniValue transactions(UniValue::VARR); if (it != mapTally.end()) { - BOOST_FOREACH (const uint256& item, (*it).second.txids) { + for (const uint256& item : (*it).second.txids) { transactions.push_back(item.GetHex()); } } @@ -1258,7 +1258,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe // Sent if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) { - BOOST_FOREACH (const COutputEntry& s, listSent) { + for (const COutputEntry& s : listSent) { UniValue entry(UniValue::VOBJ); if (involvesWatchonly || (::IsMine(*pwalletMain, s.destination) & ISMINE_WATCH_ONLY)) entry.push_back(Pair("involvesWatchonly", true)); @@ -1277,7 +1277,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe // Received if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) { - BOOST_FOREACH (const COutputEntry& r, listReceived) { + for (const COutputEntry& r : listReceived) { string account; if (pwalletMain->mapAddressBook.count(r.destination)) account = pwalletMain->mapAddressBook[r.destination].name; @@ -1483,7 +1483,7 @@ UniValue listaccounts(const UniValue& params, bool fHelp) includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY; map mapAccountBalances; - BOOST_FOREACH (const PAIRTYPE(CTxDestination, CAddressBookData) & entry, pwalletMain->mapAddressBook) { + for (const PAIRTYPE(CTxDestination, CAddressBookData) & entry : pwalletMain->mapAddressBook) { if (IsMine(*pwalletMain, entry.first) & includeWatchonly) // This address belongs to me mapAccountBalances[entry.second.name] = 0; } @@ -1499,10 +1499,10 @@ UniValue listaccounts(const UniValue& params, bool fHelp) continue; wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly); mapAccountBalances[strSentAccount] -= nFee; - BOOST_FOREACH (const COutputEntry& s, listSent) + for (const COutputEntry& s : listSent) mapAccountBalances[strSentAccount] -= s.amount; if (nDepth >= nMinDepth) { - BOOST_FOREACH (const COutputEntry& r, listReceived) + for (const COutputEntry& r : listReceived) if (pwalletMain->mapAddressBook.count(r.destination)) mapAccountBalances[pwalletMain->mapAddressBook[r.destination].name] += r.amount; else @@ -1511,11 +1511,11 @@ UniValue listaccounts(const UniValue& params, bool fHelp) } const list & acentries = pwalletMain->laccentries; - BOOST_FOREACH (const CAccountingEntry& entry, acentries) + for (const CAccountingEntry& entry : acentries) mapAccountBalances[entry.strAccount] += entry.nCreditDebit; UniValue ret(UniValue::VOBJ); - BOOST_FOREACH (const PAIRTYPE(string, CAmount) & accountBalance, mapAccountBalances) { + for (const PAIRTYPE(string, CAmount) & accountBalance : mapAccountBalances) { ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); } return ret; @@ -2076,7 +2076,7 @@ UniValue listlockunspent(const UniValue& params, bool fHelp) UniValue ret(UniValue::VARR); - BOOST_FOREACH (COutPoint& outpt, vOutpts) { + for (COutPoint& outpt : vOutpts) { UniValue o(UniValue::VOBJ); o.push_back(Pair("txid", outpt.hash.GetHex())); @@ -2329,7 +2329,7 @@ UniValue printAddresses() std::vector vCoins; pwalletMain->AvailableCoins(vCoins); std::map mapAddresses; - BOOST_FOREACH (const COutput& out, vCoins) { + for (const COutput& out : vCoins) { CTxDestination utxoAddress; ExtractDestination(out.tx->vout[out.i].scriptPubKey, utxoAddress); std::string strAdd = CBitcoinAddress(utxoAddress).ToString(); diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index d82070c22f3df..f50d66f3f809a 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -52,7 +52,7 @@ static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = fa static void empty_wallet(void) { - BOOST_FOREACH(COutput output, vCoins) + for (COutput output : vCoins) delete output.tx; vCoins.clear(); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 50827720fbe6d..4a3bc2cdd5701 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -272,7 +272,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool anonymizeOnly { LOCK(cs_wallet); - BOOST_FOREACH (const MasterKeyMap::value_type& pMasterKey, mapMasterKeys) { + for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys) { if (!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) @@ -297,7 +297,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, CCrypter crypter; CKeyingMaterial vMasterKey; - BOOST_FOREACH (MasterKeyMap::value_type& pMasterKey, mapMasterKeys) { + for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys) { if (!crypter.SetKeyFromPassphrase(strOldWalletPassphraseFinal, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) @@ -388,7 +388,7 @@ set CWallet::GetConflicts(const uint256& txid) const std::pair range; - BOOST_FOREACH (const CTxIn& txin, wtx.vin) { + for (const CTxIn& txin : wtx.vin) { if (mapTxSpends.count(txin.prevout) <= 1 || wtx.HasZerocoinSpendInputs()) continue; // No conflict if zero or one spends range = mapTxSpends.equal_range(txin.prevout); @@ -465,7 +465,7 @@ void CWallet::AddToSpends(const uint256& wtxid) if (thisTx.IsCoinBase()) // Coinbases don't spend anything! return; - BOOST_FOREACH (const CTxIn& txin, thisTx.vin) + for (const CTxIn& txin : thisTx.vin) AddToSpends(txin.prevout, wtxid); } @@ -496,7 +496,7 @@ bool CWallet::GetMasternodeVinAndKeys(CTxIn& txinRet, CPubKey& pubKeyRet, CKey& return false; } - BOOST_FOREACH (COutput& out, vPossibleCoins) + for (COutput& out : vPossibleCoins) if (out.tx->GetHash() == txHash && out.i == nOutputIndex) // found it! return GetVinAndKeysFromOutput(out, txinRet, pubKeyRet, keyRet); @@ -638,7 +638,7 @@ void CWallet::MarkDirty() { { LOCK(cs_wallet); - BOOST_FOREACH (PAIRTYPE(const uint256, CWalletTx) & item, mapWallet) + for (PAIRTYPE(const uint256, CWalletTx) & item : mapWallet) item.second.MarkDirty(); } } @@ -743,7 +743,7 @@ void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock) // If a transaction changes 'conflicted' state, that changes the balance // available of the outputs it spends. So force those to be // recomputed, also: - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { if (!txin.IsZerocoinSpend() && mapWallet.count(txin.prevout.hash)) mapWallet[txin.prevout.hash].MarkDirty(); } @@ -862,7 +862,7 @@ int CWallet::GetRealInputObfuscationRounds(CTxIn in, int rounds) const } bool fAllDenoms = true; - BOOST_FOREACH (CTxOut out, wtx->vout) { + for (CTxOut out : wtx->vout) { fAllDenoms = fAllDenoms && IsDenominatedAmount(out.nValue); } // this one is denominated but there is another non-denominated output found in the same tx @@ -875,7 +875,7 @@ int CWallet::GetRealInputObfuscationRounds(CTxIn in, int rounds) const int nShortest = -10; // an initial value, should be no way to get this by calculations bool fDenomFound = false; // only denoms here so let's look up - BOOST_FOREACH (CTxIn in2, wtx->vin) { + for (CTxIn in2 : wtx->vin) { if (IsMine(in2)) { int n = GetRealInputObfuscationRounds(in2, rounds + 1); // denom found, find the shortest chain or initially assign nShortest with the first found value @@ -922,7 +922,7 @@ bool CWallet::IsDenominated(const CTransaction& tx) const Return false if ANY inputs are non-denom */ bool ret = true; - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { if (!IsDenominated(txin)) { ret = false; } @@ -933,7 +933,7 @@ bool CWallet::IsDenominated(const CTransaction& tx) const bool CWallet::IsDenominatedAmount(CAmount nInputAmount) const { - BOOST_FOREACH (CAmount d, obfuScationDenominations) + for (CAmount d : obfuScationDenominations) if (nInputAmount == d) return true; return false; @@ -1425,13 +1425,13 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived, GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); if (strAccount == strSentAccount) { - BOOST_FOREACH (const COutputEntry& s, listSent) + for (const COutputEntry& s : listSent) nSent += s.amount; nFee = allFee; } { LOCK(pwallet->cs_wallet); - BOOST_FOREACH (const COutputEntry& r, listReceived) { + for (const COutputEntry& r : listReceived) { if (pwallet->mapAddressBook.count(r.destination)) { map::const_iterator mi = pwallet->mapAddressBook.find(r.destination); if (mi != pwallet->mapAddressBook.end() && (*mi).second.name == strAccount) @@ -1481,7 +1481,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) CBlock block; ReadBlockFromDisk(block, pindex); - BOOST_FOREACH (CTransaction& tx, block.vtx) { + for (CTransaction& tx : block.vtx) { if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) ret++; } @@ -1546,7 +1546,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) void CWallet::ReacceptWalletTransactions() { LOCK2(cs_main, cs_wallet); - BOOST_FOREACH (PAIRTYPE(const uint256, CWalletTx) & item, mapWallet) { + for (PAIRTYPE(const uint256, CWalletTx) & item : mapWallet) { const uint256& wtxid = item.first; CWalletTx& wtx = item.second; assert(wtx.GetHash() == wtxid); @@ -1622,14 +1622,14 @@ void CWallet::ResendWalletTransactions() LOCK(cs_wallet); // Sort them in chronological order multimap mapSorted; - BOOST_FOREACH (PAIRTYPE(const uint256, CWalletTx) & item, mapWallet) { + for (PAIRTYPE(const uint256, CWalletTx) & item : mapWallet) { CWalletTx& wtx = item.second; // Don't rebroadcast until it's had plenty of time that // it should have gotten in already by now. if (nTimeBestReceived - (int64_t)wtx.nTimeReceived > 5 * 60) mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx)); } - BOOST_FOREACH (PAIRTYPE(const unsigned int, CWalletTx*) & item, mapSorted) { + for (PAIRTYPE(const unsigned int, CWalletTx*) & item : mapSorted) { CWalletTx& wtx = *item.second; wtx.RelayWalletTransaction(); } @@ -2041,7 +2041,7 @@ map > CWallet::AvailableCoinsByAddress(bool fCo AvailableCoins(vCoins, fConfirmed); map > mapCoins; - BOOST_FOREACH (COutput out, vCoins) { + for (COutput out : vCoins) { if (maxCoinValue > 0 && out.tx->vout[out.i].nValue > maxCoinValue) continue; @@ -2104,7 +2104,7 @@ bool less_then_denom(const COutput& out1, const COutput& out2) bool found1 = false; bool found2 = false; - BOOST_FOREACH (CAmount d, obfuScationDenominations) // loop through predefined denoms + for (CAmount d : obfuScationDenominations) // loop through predefined denoms { if (pcoin1->vout[out1.i].nValue == d) found1 = true; if (pcoin2->vout[out2.i].nValue == d) found2 = true; @@ -2249,7 +2249,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int if (fDebug) LogPrint("selectcoins", "tryDenom: %d\n", tryDenom); vValue.clear(); nTotalLower = 0; - BOOST_FOREACH (const COutput& output, vCoins) { + for (const COutput& output : vCoins) { if (!output.fSpendable) continue; @@ -2343,7 +2343,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set return all selected outputs (we want all selected to go into the transaction for sure) if (coinControl && coinControl->HasSelected()) { - BOOST_FOREACH (const COutput& out, vCoins) { + for (const COutput& out : vCoins) { if (!out.fSpendable) continue; @@ -2363,8 +2363,8 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue == v //make sure it's the denom we're looking for && nValueRet + out.tx->vout[out.i].nValue < nTargetValue + (0.1 * COIN) + 100 //round the amount up to .1 PIV over ) { @@ -2420,7 +2420,7 @@ bool CWallet::SelectCoinsByDenominations(int nDenom, CAmount nValueMin, CAmount if (!(nDenom & (1 << 4))) fFound1 = true; if (!(nDenom & (1 << 5))) fFoundDot1 = true; - BOOST_FOREACH (const COutput& out, vCoins) { + for (const COutput& out : vCoins) { // masternode-like input should not be selected by AvailableCoins now anyway //if(out.tx->vout[out.i].nValue == 10000*COIN) continue; if (nValueRet + out.tx->vout[out.i].nValue <= nValueMax) { @@ -2513,7 +2513,7 @@ bool CWallet::SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector< //order the array so largest nondenom are first, then denominations, then very small inputs. sort(vCoins.rbegin(), vCoins.rend(), CompareByPriority()); - BOOST_FOREACH (const COutput& out, vCoins) { + for (const COutput& out : vCoins) { //do not allow inputs less than 1 CENT if (out.tx->vout[out.i].nValue < CENT) continue; //do not allow collaterals to be selected @@ -2551,7 +2551,7 @@ bool CWallet::SelectCoinsCollateral(std::vector& setCoinsRet, CAmount& nV set > setCoinsRet2; - BOOST_FOREACH (const COutput& out, vCoins) { + for (const COutput& out : vCoins) { // collateral inputs will always be a multiple of DARSEND_COLLATERAL, up to five if (IsCollateralAmount(out.tx->vout[out.i].nValue)) { CTxIn vin = CTxIn(out.tx->GetHash(), out.i); @@ -2600,7 +2600,7 @@ bool CWallet::HasCollateralInputs(bool fOnlyConfirmed) const AvailableCoins(vCoins, fOnlyConfirmed); int nFound = 0; - BOOST_FOREACH (const COutput& out, vCoins) + for (const COutput& out : vCoins) if (IsCollateralAmount(out.tx->vout[out.i].nValue)) nFound++; return nFound > 0; @@ -2638,7 +2638,7 @@ bool CWallet::CreateCollateralTransaction(CMutableTransaction& txCollateral, std scriptChange = GetScriptForDestination(vchPubKey.GetID()); reservekey.KeepKey(); - BOOST_FOREACH (CTxIn v, vCoinsCollateral) + for (CTxIn v : vCoinsCollateral) txCollateral.vin.push_back(v); if (nValueIn2 - OBFUSCATION_COLLATERAL - nFeeRet > 0) { @@ -2648,9 +2648,9 @@ bool CWallet::CreateCollateralTransaction(CMutableTransaction& txCollateral, std } int vinNumber = 0; - BOOST_FOREACH (CTxIn v, txCollateral.vin) { + for (CTxIn v : txCollateral.vin) { if (!SignSignature(*this, v.prevPubKey, txCollateral, vinNumber, int(SIGHASH_ALL | SIGHASH_ANYONECANPAY))) { - BOOST_FOREACH (CTxIn v, vCoinsCollateral) + for (CTxIn v : vCoinsCollateral) UnlockCoin(v.prevout); strReason = "CObfuscationPool::Sign - Unable to sign collateral transaction! \n"; @@ -2710,7 +2710,7 @@ bool CWallet::GetBudgetFinalizationCollateralTX(CWalletTx& tx, uint256 hash, boo bool CWallet::ConvertList(std::vector vCoins, std::vector& vecAmounts) { - BOOST_FOREACH (CTxIn i, vCoins) { + for (CTxIn i : vCoins) { if (mapWallet.count(i.prevout.hash)) { CWalletTx& wtx = mapWallet[i.prevout.hash]; if (i.prevout.n < wtx.vout.size()) { @@ -2737,7 +2737,7 @@ bool CWallet::CreateTransaction(const vector >& vecSend, CAmount nValue = 0; - BOOST_FOREACH (const PAIRTYPE(CScript, CAmount) & s, vecSend) { + for (const PAIRTYPE(CScript, CAmount) & s : vecSend) { if (nValue < 0) { strFailReason = _("Transaction amounts must be positive"); return false; @@ -2768,7 +2768,7 @@ bool CWallet::CreateTransaction(const vector >& vecSend, // vouts to the payees if (coinControl && !coinControl->fSplitBlock) { - BOOST_FOREACH (const PAIRTYPE(CScript, CAmount) & s, vecSend) { + for (const PAIRTYPE(CScript, CAmount) & s : vecSend) { CTxOut txout(s.second, s.first); if (txout.IsDust(::minRelayTxFee)) { strFailReason = _("Transaction amount too small"); @@ -2785,7 +2785,7 @@ bool CWallet::CreateTransaction(const vector >& vecSend, else nSplitBlock = 1; - BOOST_FOREACH (const PAIRTYPE(CScript, CAmount) & s, vecSend) { + for (const PAIRTYPE(CScript, CAmount) & s : vecSend) { for (int i = 0; i < nSplitBlock; i++) { if (i == nSplitBlock - 1) { uint64_t nRemainder = s.second % nSplitBlock; @@ -2820,7 +2820,7 @@ bool CWallet::CreateTransaction(const vector >& vecSend, } - BOOST_FOREACH (PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) { + for (PAIRTYPE(const CWalletTx*, unsigned int) pcoin : setCoins) { CAmount nCredit = pcoin.first->vout[pcoin.second].nValue; //The coin age after the next block (depth+1) is used instead of the current, //reflecting an assumption the user would accept a bit more delay for @@ -2902,12 +2902,12 @@ bool CWallet::CreateTransaction(const vector >& vecSend, reservekey.ReturnKey(); // Fill vin - BOOST_FOREACH (const PAIRTYPE(const CWalletTx*, unsigned int) & coin, setCoins) + for (const PAIRTYPE(const CWalletTx*, unsigned int) & coin : setCoins) txNew.vin.push_back(CTxIn(coin.first->GetHash(), coin.second)); // Sign int nIn = 0; - BOOST_FOREACH (const PAIRTYPE(const CWalletTx*, unsigned int) & coin, setCoins) + for (const PAIRTYPE(const CWalletTx*, unsigned int) & coin : setCoins) if (!SignSignature(*this, *coin.first, txNew, nIn++)) { strFailReason = _("Signing transaction failed"); return false; @@ -3171,7 +3171,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, std: // Notify that old coins are spent if (!wtxNew.HasZerocoinSpendInputs()) { set updated_hahes; - BOOST_FOREACH (const CTxIn& txin, wtxNew.vin) { + for (const CTxIn& txin : wtxNew.vin) { // notify only once if (updated_hahes.find(txin.prevout.hash) != updated_hahes.end()) continue; @@ -3239,7 +3239,7 @@ CAmount CWallet::GetTotalValue(std::vector vCoins) { CAmount nTotalValue = 0; CWalletTx wtx; - BOOST_FOREACH (CTxIn i, vCoins) { + for (CTxIn i : vCoins) { if (mapWallet.count(i.prevout.hash)) { CWalletTx& wtx = mapWallet[i.prevout.hash]; if (i.prevout.n < wtx.vout.size()) { @@ -3282,7 +3282,7 @@ string CWallet::PrepareObfuscationDenominate(int minRounds, int maxRounds) { LOCK(cs_wallet); - BOOST_FOREACH (CTxIn v, vCoins) + for (CTxIn v : vCoins) LockCoin(v.prevout); } @@ -3300,7 +3300,7 @@ string CWallet::PrepareObfuscationDenominate(int minRounds, int maxRounds) int nStep = 0; int nStepsMax = 5 + GetRandInt(5); while (nStep < nStepsMax) { - BOOST_FOREACH (CAmount v, obfuScationDenominations) { + for (CAmount v : obfuScationDenominations) { // only use the ones that are approved bool fAccepted = false; if ((obfuScationPool.sessionDenom & (1 << 0)) && v == ((10000 * COIN) + 10000000)) { @@ -3362,14 +3362,14 @@ string CWallet::PrepareObfuscationDenominate(int minRounds, int maxRounds) { // unlock unused coins LOCK(cs_wallet); - BOOST_FOREACH (CTxIn v, vCoins) + for (CTxIn v : vCoins) UnlockCoin(v.prevout); } if (obfuScationPool.GetDenominations(vOut) != obfuScationPool.sessionDenom) { // unlock used coins on failure LOCK(cs_wallet); - BOOST_FOREACH (CTxIn v, vCoinsResult) + for (CTxIn v : vCoinsResult) UnlockCoin(v.prevout); return "Error: can't make current denominated outputs"; } @@ -3458,7 +3458,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address) if (fFileBacked) { // Delete destdata tuples associated with address std::string strAddress = CBitcoinAddress(address).ToString(); - BOOST_FOREACH (const PAIRTYPE(string, string) & item, mapAddressBook[address].destdata) { + for (const PAIRTYPE(string, string) & item : mapAddressBook[address].destdata) { CWalletDB(strWalletFile).EraseDestData(strAddress, item.first); } } @@ -3492,7 +3492,7 @@ bool CWallet::NewKeyPool() { LOCK(cs_wallet); CWalletDB walletdb(strWalletFile); - BOOST_FOREACH (int64_t nIndex, setKeyPool) + for (int64_t nIndex : setKeyPool) walletdb.ErasePool(nIndex); setKeyPool.clear(); @@ -3625,7 +3625,7 @@ std::map CWallet::GetAddressBalances() { LOCK(cs_wallet); - BOOST_FOREACH (PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet) { + for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet) { CWalletTx* pcoin = &walletEntry.second; if (!IsFinalTx(*pcoin) || !pcoin->IsTrusted()) @@ -3663,13 +3663,13 @@ set > CWallet::GetAddressGroupings() set > groupings; set grouping; - BOOST_FOREACH (PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet) { + for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet) { CWalletTx* pcoin = &walletEntry.second; if (pcoin->vin.size() > 0) { bool any_mine = false; // group all input addresses with each other - BOOST_FOREACH (CTxIn txin, pcoin->vin) { + for (CTxIn txin : pcoin->vin) { CTxDestination address; if (!IsMine(txin)) /* If this input isn't mine, ignore it */ continue; @@ -3681,7 +3681,7 @@ set > CWallet::GetAddressGroupings() // group change with input addresses if (any_mine) { - BOOST_FOREACH (CTxOut txout, pcoin->vout) + for (CTxOut txout : pcoin->vout) if (IsChange(txout)) { CTxDestination txoutAddr; if (!ExtractDestination(txout.scriptPubKey, txoutAddr)) @@ -3709,17 +3709,17 @@ set > CWallet::GetAddressGroupings() set*> uniqueGroupings; // a set of pointers to groups of addresses map*> setmap; // map addresses to the unique group containing it - BOOST_FOREACH (set grouping, groupings) { + for (set grouping : groupings) { // make a set of all the groups hit by this new group set*> hits; map*>::iterator it; - BOOST_FOREACH (CTxDestination address, grouping) + for (CTxDestination address : grouping) if ((it = setmap.find(address)) != setmap.end()) hits.insert((*it).second); // merge all hit groups into a new single group and delete old groups set* merged = new set(grouping); - BOOST_FOREACH (set* hit, hits) { + for (set* hit : hits) { merged->insert(hit->begin(), hit->end()); uniqueGroupings.erase(hit); delete hit; @@ -3727,12 +3727,12 @@ set > CWallet::GetAddressGroupings() uniqueGroupings.insert(merged); // update setmap - BOOST_FOREACH (CTxDestination element, *merged) + for (CTxDestination element : *merged) setmap[element] = merged; } set > ret; - BOOST_FOREACH (set* uniqueGrouping, uniqueGroupings) { + for (set* uniqueGrouping : uniqueGroupings) { ret.insert(*uniqueGrouping); delete uniqueGrouping; } @@ -3744,7 +3744,7 @@ set CWallet::GetAccountAddresses(string strAccount) const { LOCK(cs_wallet); set result; - BOOST_FOREACH (const PAIRTYPE(CTxDestination, CAddressBookData) & item, mapAddressBook) { + for (const PAIRTYPE(CTxDestination, CAddressBookData) & item : mapAddressBook) { const CTxDestination& address = item.first; const string& strName = item.second.name; if (strName == strAccount) @@ -3792,7 +3792,7 @@ void CWallet::GetAllReserveKeys(set& setAddress) const CWalletDB walletdb(strWalletFile); LOCK2(cs_main, cs_wallet); - BOOST_FOREACH (const int64_t& id, setKeyPool) { + for (const int64_t& id : setKeyPool) { CKeyPool keypool; if (!walletdb.ReadPool(id, keypool)) throw runtime_error("GetAllReserveKeyHashes() : read failed"); @@ -3871,7 +3871,7 @@ class CAffectedKeysVisitor : public boost::static_visitor std::vector vDest; int nRequired; if (ExtractDestinations(script, type, vDest, nRequired)) { - BOOST_FOREACH (const CTxDestination& dest, vDest) + for (const CTxDestination& dest : vDest) boost::apply_visitor(*this, dest); } } @@ -3907,7 +3907,7 @@ void CWallet::GetKeyBirthTimes(std::map& mapKeyBirth) const std::map mapKeyFirstBlock; std::set setKeys; GetKeys(setKeys); - BOOST_FOREACH (const CKeyID& keyid, setKeys) { + for (const CKeyID& keyid : setKeys) { if (mapKeyBirth.count(keyid) == 0) mapKeyFirstBlock[keyid] = pindexMax; } @@ -3926,10 +3926,10 @@ void CWallet::GetKeyBirthTimes(std::map& mapKeyBirth) const if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) { // ... which are already in a block int nHeight = blit->second->nHeight; - BOOST_FOREACH (const CTxOut& txout, wtx.vout) { + for (const CTxOut& txout : wtx.vout) { // iterate over all their outputs CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey); - BOOST_FOREACH (const CKeyID& keyid, vAffected) { + for (const CKeyID& keyid : vAffected) { // ... and all their affected keys std::map::iterator rit = mapKeyFirstBlock.find(keyid); if (rit != mapKeyFirstBlock.end() && nHeight < rit->second->nHeight) @@ -4206,7 +4206,7 @@ void CWallet::AutoCombineDust() //find masternode rewards that need to be combined CCoinControl* coinControl = new CCoinControl(); CAmount nTotalRewardsValue = 0; - BOOST_FOREACH (const COutput& out, vCoins) { + for (const COutput& out : vCoins) { if (!out.fSpendable) continue; //no coins should get this far if they dont have proper maturity, this is double checking diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index fef7ce6ffae51..6186b916d76e0 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -579,7 +579,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface } bool IsMine(const CTransaction& tx) const { - BOOST_FOREACH (const CTxOut& txout, tx.vout) + for (const CTxOut& txout : tx.vout) if (IsMine(txout)) return true; return false; @@ -592,7 +592,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const { CAmount nDebit = 0; - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { nDebit += GetDebit(txin, filter); if (!MoneyRange(nDebit)) throw std::runtime_error("CWallet::GetDebit() : value out of range"); @@ -602,7 +602,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const { CAmount nCredit = 0; - BOOST_FOREACH (const CTxOut& txout, tx.vout) { + for (const CTxOut& txout : tx.vout) { nCredit += GetCredit(txout, filter); if (!MoneyRange(nCredit)) throw std::runtime_error("CWallet::GetCredit() : value out of range"); @@ -612,7 +612,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface CAmount GetChange(const CTransaction& tx) const { CAmount nChange = 0; - BOOST_FOREACH (const CTxOut& txout, tx.vout) { + for (const CTxOut& txout : tx.vout) { nChange += GetChange(txout); if (!MoneyRange(nChange)) throw std::runtime_error("CWallet::GetChange() : value out of range"); @@ -1041,7 +1041,7 @@ class CWalletTx : public CMerkleTx return false; // Trusted if all inputs are from us and are in the mempool: - BOOST_FOREACH (const CTxIn& txin, vin) { + for (const CTxIn& txin : vin) { // Transactions not sent by us: not trusted const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash); if (parent == NULL) @@ -1083,7 +1083,7 @@ class COutput //Used with Obfuscation. Will return largest nondenom, then denominations, then very small inputs int Priority() const { - BOOST_FOREACH (CAmount d, obfuScationDenominations) + for (CAmount d : obfuScationDenominations) if (tx->vout[i].nValue == d) return 10000; if (tx->vout[i].nValue < 1 * COIN) return 20000; diff --git a/src/wallet/wallet_ismine.cpp b/src/wallet/wallet_ismine.cpp index 226d612f52cc9..194c3b7b177d5 100644 --- a/src/wallet/wallet_ismine.cpp +++ b/src/wallet/wallet_ismine.cpp @@ -21,7 +21,7 @@ typedef vector valtype; unsigned int HaveKeys(const vector& pubkeys, const CKeyStore& keystore) { unsigned int nResult = 0; - BOOST_FOREACH (const valtype& pubkey, pubkeys) { + for (const valtype& pubkey : pubkeys) { CKeyID keyID = CPubKey(pubkey).GetID(); if(keystore.HaveKey(keyID)) ++nResult; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index d5df4e390e379..aa343d53c9a25 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -342,7 +342,7 @@ CAmount CWalletDB::GetAccountCreditDebit(const string& strAccount) ListAccountCreditDebit(strAccount, entries); CAmount nCreditDebit = 0; - BOOST_FOREACH (const CAccountingEntry& entry, entries) + for (const CAccountingEntry& entry : entries) nCreditDebit += entry.nCreditDebit; return nCreditDebit; @@ -406,7 +406,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet) } list acentries; ListAccountCreditDebit("", acentries); - BOOST_FOREACH (CAccountingEntry& entry, acentries) { + for (CAccountingEntry& entry : acentries) { txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); } @@ -429,7 +429,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet) return DB_LOAD_FAIL; } else { int64_t nOrderPosOff = 0; - BOOST_FOREACH (const int64_t& nOffsetStart, nOrderPosOffsets) { + for (const int64_t& nOffsetStart : nOrderPosOffsets) { if (nOrderPos >= nOffsetStart) ++nOrderPosOff; } @@ -803,7 +803,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if ((wss.nKeys + wss.nCKeys) != wss.nKeyMeta) pwallet->nTimeFirstKey = 1; // 0 would be considered 'no value' - BOOST_FOREACH (uint256 hash, wss.vWalletUpgrade) + for (uint256 hash : wss.vWalletUpgrade) WriteTx(hash, pwallet->mapWallet[hash]); // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: @@ -818,7 +818,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) pwallet->laccentries.clear(); ListAccountCreditDebit("*", pwallet->laccentries); - BOOST_FOREACH(CAccountingEntry& entry, pwallet->laccentries) { + for (CAccountingEntry& entry : pwallet->laccentries) { pwallet->wtxOrdered.insert(make_pair(entry.nOrderPos, CWallet::TxPair((CWalletTx*)0, &entry))); } @@ -894,7 +894,7 @@ DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet, vector& vWtx) return err; // erase each wallet TX - BOOST_FOREACH (uint256& hash, vTxHash) { + for (uint256& hash : vTxHash) { if (!EraseTx(hash)) return DB_CORRUPT; } @@ -1147,7 +1147,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys) CWalletScanState wss; DbTxn* ptxn = dbenv.TxnBegin(); - BOOST_FOREACH (CDBEnv::KeyValPair& row, salvagedData) { + for (CDBEnv::KeyValPair& row : salvagedData) { if (fOnlyKeys) { CDataStream ssKey(row.first, SER_DISK, CLIENT_VERSION); CDataStream ssValue(row.second, SER_DISK, CLIENT_VERSION);