From a5410ac5ece4ef4d52eab07201c5f6c6c4501921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Thu, 1 Jun 2017 22:22:33 +0200 Subject: [PATCH 1/4] Small preparations for Q_FOREACH, PAIRTYPE and #include removal --- src/httprpc.cpp | 2 +- src/qt/platformstyle.cpp | 3 +-- src/utilstrencodings.h | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 5ab6d8d73..f1eb1c36e 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -19,7 +19,7 @@ #include "utilstrencodings.h" #include // boost::trim -#include //BOOST_FOREACH +#include /** WWW-Authenticate to present with 401 Unauthorized response */ static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\""; diff --git a/src/qt/platformstyle.cpp b/src/qt/platformstyle.cpp index 90bd619c0..64a0d0058 100644 --- a/src/qt/platformstyle.cpp +++ b/src/qt/platformstyle.cpp @@ -48,8 +48,7 @@ void MakeSingleColorImage(QImage& img, const QColor& colorbase) QIcon ColorizeIcon(const QIcon& ico, const QColor& colorbase) { QIcon new_ico; - QSize sz; - Q_FOREACH(sz, ico.availableSizes()) + Q_FOREACH(const QSize sz, ico.availableSizes()) { QImage img(ico.pixmap(sz).toImage()); MakeSingleColorImage(img, colorbase); diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index e2a1b9bef..8846cb47e 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -18,8 +18,6 @@ #define UBEGIN(a) ((unsigned char*)&(a)) #define UEND(a) ((unsigned char*)&((&(a))[1])) #define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0])) - -/** This is needed because the foreach macro can't get over the comma in pair */ #define PAIRTYPE(t1, t2) std::pair /** Used by SanitizeString() */ From 7c00c267264ad80c2991b2f6c2ae08c2d9c9732b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Fri, 2 Jun 2017 03:18:57 +0200 Subject: [PATCH 2/4] scripted-diff: Fully remove BOOST_FOREACH -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/bench/coin_selection.cpp | 2 +- src/bitcoin-tx.cpp | 2 +- src/bloom.cpp | 2 +- src/checkqueue.h | 4 +- src/core_write.cpp | 2 +- src/httprpc.cpp | 2 +- src/init.cpp | 18 +++--- src/miner.cpp | 6 +- src/net.cpp | 68 ++++++++++----------- src/net_processing.cpp | 34 +++++------ src/policy/policy.cpp | 4 +- src/policy/rbf.cpp | 4 +- src/qt/addresstablemodel.cpp | 2 +- src/qt/coincontroldialog.cpp | 6 +- src/qt/peertablemodel.cpp | 2 +- src/qt/recentrequeststablemodel.cpp | 2 +- src/qt/transactiondesc.cpp | 18 +++--- src/qt/transactionrecord.cpp | 4 +- src/qt/walletmodel.cpp | 2 +- src/rest.cpp | 6 +- src/rpc/blockchain.cpp | 20 +++---- src/rpc/mining.cpp | 2 +- src/rpc/misc.cpp | 2 +- src/rpc/net.cpp | 10 ++-- src/rpc/rawtransaction.cpp | 8 +-- src/rpc/server.cpp | 6 +- src/script/ismine.cpp | 2 +- src/script/sign.cpp | 8 +-- src/script/standard.cpp | 4 +- src/sync.cpp | 10 ++-- src/test/bip32_tests.cpp | 2 +- src/test/coins_tests.cpp | 2 +- src/test/getarg_tests.cpp | 2 +- src/test/multisig_tests.cpp | 2 +- src/test/prevector_tests.cpp | 4 +- src/test/script_tests.cpp | 4 +- src/test/test_bitcoin.cpp | 2 +- src/test/transaction_tests.cpp | 4 +- src/timedata.cpp | 4 +- src/torcontrol.cpp | 6 +- src/txmempool.cpp | 54 ++++++++--------- src/validation.cpp | 40 ++++++------- src/wallet/crypter.cpp | 2 +- src/wallet/db.cpp | 2 +- src/wallet/rpcdump.cpp | 4 +- src/wallet/rpcwallet.cpp | 34 +++++------ src/wallet/test/accounting_tests.cpp | 2 +- src/wallet/wallet.cpp | 90 ++++++++++++++-------------- src/wallet/walletdb.cpp | 10 ++-- 49 files changed, 266 insertions(+), 266 deletions(-) diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index 42891f345..942942c29 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -39,7 +39,7 @@ static void CoinSelection(benchmark::State& state) while (state.KeepRunning()) { // Empty wallet. - BOOST_FOREACH (COutput output, vCoins) + for (COutput output : vCoins) delete output.tx; vCoins.clear(); diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index cf280f485..8d43822f8 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -611,7 +611,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr) ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata); // ... and merge in other signatures: - BOOST_FOREACH(const CTransaction& txv, txVariants) + for (const CTransaction& txv : txVariants) sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i)); UpdateTransaction(mergedTx, i, sigdata); diff --git a/src/bloom.cpp b/src/bloom.cpp index 7ed982c98..cc3baa918 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -179,7 +179,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)) diff --git a/src/checkqueue.h b/src/checkqueue.h index 63c104c02..ff10b9938 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -121,7 +121,7 @@ private: fOk = fAllOk; } // execute work - BOOST_FOREACH (T& check, vChecks) + for (T& check : vChecks) if (fOk) fOk = check(); vChecks.clear(); @@ -151,7 +151,7 @@ public: 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/core_write.cpp b/src/core_write.cpp index d116e617e..5271b01b8 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -141,7 +141,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/httprpc.cpp b/src/httprpc.cpp index f1eb1c36e..f6d42bf7e 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -95,7 +95,7 @@ static bool multiUserAuthorized(std::string strUserPass) if (gArgs.IsArgSet("-rpcauth")) { //Search for multi-user login/pass "rpcauth" from config - BOOST_FOREACH(std::string strRPCAuth, gArgs.GetArgs("-rpcauth")) + for (std::string strRPCAuth : gArgs.GetArgs("-rpcauth")) { std::vector vFields; boost::split(vFields, strRPCAuth, boost::is_any_of(":$")); diff --git a/src/init.cpp b/src/init.cpp index 33023a180..2c1f93727 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -611,7 +611,7 @@ void CleanupBlockRevFiles() // keeping a separate counter. Once we hit a gap (or if 0 doesn't exist) // start removing block files. int nContigCounter = 0; - BOOST_FOREACH(const PAIRTYPE(std::string, fs::path)& item, mapBlockFiles) { + for (const PAIRTYPE(std::string, fs::path)& item : mapBlockFiles) { if (atoi(item.first) == nContigCounter) { nContigCounter++; continue; @@ -664,7 +664,7 @@ void ThreadImport(std::vector vImportFiles) } // -loadblock= - BOOST_FOREACH(const fs::path& path, vImportFiles) { + for (const fs::path& path : vImportFiles) { FILE *file = fsbridge::fopen(path, "rb"); if (file) { LogPrintf("Importing blocks file %s...\n", path.string()); @@ -1258,7 +1258,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) // sanitize comments per BIP-0014, format user agent and check total size std::vector uacomments; if (gArgs.IsArgSet("-uacomment")) { - BOOST_FOREACH(std::string cmt, gArgs.GetArgs("-uacomment")) + for (std::string cmt : gArgs.GetArgs("-uacomment")) { if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)) return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt)); @@ -1273,7 +1273,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) if (gArgs.IsArgSet("-onlynet")) { std::set nets; - BOOST_FOREACH(const std::string& snet, gArgs.GetArgs("-onlynet")) { + for (const std::string& snet : gArgs.GetArgs("-onlynet")) { enum Network net = ParseNetwork(snet); if (net == NET_UNROUTABLE) return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet)); @@ -1287,7 +1287,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) } if (gArgs.IsArgSet("-whitelist")) { - BOOST_FOREACH(const std::string& net, gArgs.GetArgs("-whitelist")) { + for (const std::string& net : gArgs.GetArgs("-whitelist")) { CSubNet subnet; LookupSubNet(net.c_str(), subnet); if (!subnet.IsValid()) @@ -1349,7 +1349,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) if (fListen) { bool fBound = false; if (gArgs.IsArgSet("-bind")) { - BOOST_FOREACH(const std::string& strBind, gArgs.GetArgs("-bind")) { + for (const std::string& strBind : gArgs.GetArgs("-bind")) { CService addrBind; if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) return InitError(ResolveErrMsg("bind", strBind)); @@ -1357,7 +1357,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) } } if (gArgs.IsArgSet("-whitebind")) { - BOOST_FOREACH(const std::string& strBind, gArgs.GetArgs("-whitebind")) { + for (const std::string& strBind : gArgs.GetArgs("-whitebind")) { CService addrBind; if (!Lookup(strBind.c_str(), addrBind, 0, false)) return InitError(ResolveErrMsg("whitebind", strBind)); @@ -1377,7 +1377,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) } if (gArgs.IsArgSet("-externalip")) { - BOOST_FOREACH(const std::string& strAddr, gArgs.GetArgs("-externalip")) { + for (const std::string& strAddr : gArgs.GetArgs("-externalip")) { CService addrLocal; if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid()) AddLocal(addrLocal, LOCAL_MANUAL); @@ -1616,7 +1616,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) std::vector vImportFiles; if (gArgs.IsArgSet("-loadblock")) { - BOOST_FOREACH(const std::string& strFile, gArgs.GetArgs("-loadblock")) + for (const std::string& strFile : gArgs.GetArgs("-loadblock")) vImportFiles.push_back(strFile); } diff --git a/src/miner.cpp b/src/miner.cpp index 28b6f23d5..79016bfd3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -242,7 +242,7 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package) { uint64_t nPotentialBlockSize = nBlockSize; // only used with fNeedSizeAccounting - BOOST_FOREACH (const CTxMemPool::txiter it, package) { + for (const CTxMemPool::txiter it : package) { if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff)) return false; if (!fIncludeWitness && it->GetTx().HasWitness()) @@ -284,11 +284,11 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already indexed_modified_transaction_set &mapModifiedTx) { int nDescendantsUpdated = 0; - BOOST_FOREACH(const CTxMemPool::txiter it, alreadyAdded) { + for (const CTxMemPool::txiter it : alreadyAdded) { CTxMemPool::setEntries descendants; mempool.CalculateDescendants(it, descendants); // Insert all descendants (not yet in block) into the modified set - BOOST_FOREACH(CTxMemPool::txiter desc, descendants) { + for (CTxMemPool::txiter desc : descendants) { if (alreadyAdded.count(desc)) continue; ++nDescendantsUpdated; diff --git a/src/net.cpp b/src/net.cpp index 14ac5618e..a8119e943 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -295,7 +295,7 @@ bool IsReachable(const CNetAddr& addr) CNode* CConnman::FindNode(const CNetAddr& ip) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if ((CNetAddr)pnode->addr == ip) return (pnode); return NULL; @@ -304,7 +304,7 @@ CNode* CConnman::FindNode(const CNetAddr& ip) CNode* CConnman::FindNode(const CSubNet& subNet) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (subNet.Match((CNetAddr)pnode->addr)) return (pnode); return NULL; @@ -313,7 +313,7 @@ CNode* CConnman::FindNode(const CSubNet& subNet) CNode* CConnman::FindNode(const std::string& addrName) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (pnode->GetAddrName() == addrName) { return (pnode); } @@ -324,7 +324,7 @@ CNode* CConnman::FindNode(const std::string& addrName) CNode* CConnman::FindNode(const CService& addr) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if ((CService)pnode->addr == addr) return (pnode); return NULL; @@ -333,7 +333,7 @@ CNode* CConnman::FindNode(const CService& addr) bool CConnman::CheckIncomingNonce(uint64_t nonce) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (!pnode->fSuccessfullyConnected && !pnode->fInbound && pnode->GetLocalNonce() == nonce) return false; } @@ -528,7 +528,7 @@ void CConnman::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t ba clientInterface->BannedListChanged(); { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (subNet.Match((CNetAddr)pnode->addr)) pnode->fDisconnect = true; } @@ -606,7 +606,7 @@ void CConnman::SetBannedSetDirty(bool dirty) bool CConnman::IsWhitelistedRange(const CNetAddr &addr) { LOCK(cs_vWhitelistedRange); - BOOST_FOREACH(const CSubNet& subnet, vWhitelistedRange) { + for (const CSubNet& subnet : vWhitelistedRange) { if (subnet.Match(addr)) return true; } @@ -959,7 +959,7 @@ bool CConnman::AttemptToEvictConnection() { LOCK(cs_vNodes); - BOOST_FOREACH(CNode *node, vNodes) { + for (CNode *node : vNodes) { if (node->fWhitelisted) continue; if (!node->fInbound) @@ -1019,7 +1019,7 @@ bool CConnman::AttemptToEvictConnection() unsigned int nMostConnections = 0; int64_t nMostConnectionsTime = 0; std::map > mapNetGroupNodes; - BOOST_FOREACH(const NodeEvictionCandidate &node, vEvictionCandidates) { + for (const NodeEvictionCandidate &node : vEvictionCandidates) { mapNetGroupNodes[node.nKeyedNetGroup].push_back(node); int64_t grouptime = mapNetGroupNodes[node.nKeyedNetGroup][0].nTimeConnected; size_t groupsize = mapNetGroupNodes[node.nKeyedNetGroup].size(); @@ -1063,7 +1063,7 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) { bool whitelisted = hListenSocket.whitelisted || IsWhitelistedRange(addr); { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (pnode->fInbound) nInbound++; } @@ -1139,7 +1139,7 @@ void CConnman::ThreadSocketHandler() LOCK(cs_vNodes); // Disconnect unused nodes std::vector vNodesCopy = vNodes; - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) { if (pnode->fDisconnect) { @@ -1161,7 +1161,7 @@ void CConnman::ThreadSocketHandler() { // Delete disconnected nodes std::list vNodesDisconnectedCopy = vNodesDisconnected; - BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy) + for (CNode* pnode : vNodesDisconnectedCopy) { // wait until threads are done using it if (pnode->GetRefCount() <= 0) { @@ -1209,7 +1209,7 @@ void CConnman::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 = std::max(hSocketMax, hListenSocket.socket); have_fds = true; @@ -1217,7 +1217,7 @@ void CConnman::ThreadSocketHandler() { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) { // Implement the following logic: // * If there is data to send, select() for sending data. As this only @@ -1278,7 +1278,7 @@ void CConnman::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)) { @@ -1293,10 +1293,10 @@ void CConnman::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) { if (interruptNet) return; @@ -1417,7 +1417,7 @@ void CConnman::ThreadSocketHandler() } { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) pnode->Release(); } } @@ -1598,7 +1598,7 @@ void CConnman::ThreadDNSAddressSeed() LogPrintf("Loading addresses from DNS seeds (could take a while)\n"); - BOOST_FOREACH(const CDNSSeedData &seed, vSeeds) { + for (const CDNSSeedData &seed : vSeeds) { if (interruptNet) { return; } @@ -1610,7 +1610,7 @@ void CConnman::ThreadDNSAddressSeed() ServiceFlags requiredServiceBits = nRelevantServices; if (LookupHost(GetDNSHost(seed, &requiredServiceBits).c_str(), vIPs, 0, true)) { - BOOST_FOREACH(const CNetAddr& ip, vIPs) + for (const CNetAddr& ip : vIPs) { int nOneDay = 24*3600; CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()), requiredServiceBits); @@ -1691,7 +1691,7 @@ void CConnman::ThreadOpenConnections() for (int64_t nLoop = 0;; nLoop++) { ProcessOneShot(); - BOOST_FOREACH(const std::string& strAddr, gArgs.GetArgs("-connect")) + for (const std::string& strAddr : gArgs.GetArgs("-connect")) { CAddress addr(CService(), NODE_NONE); OpenNetworkConnection(addr, false, NULL, strAddr.c_str()); @@ -1746,7 +1746,7 @@ void CConnman::ThreadOpenConnections() std::set > setConnected; { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (!pnode->fInbound && !pnode->fAddnode) { // Count the peers that have all relevant services @@ -1863,7 +1863,7 @@ std::vector CConnman::GetAddedNodeInfo() { LOCK(cs_vAddedNodes); ret.reserve(vAddedNodes.size()); - BOOST_FOREACH(const std::string& strAddNode, vAddedNodes) + for (const std::string& strAddNode : vAddedNodes) lAddresses.push_back(strAddNode); } @@ -1884,7 +1884,7 @@ std::vector CConnman::GetAddedNodeInfo() } } - BOOST_FOREACH(const std::string& strAddNode, lAddresses) { + for (const std::string& strAddNode : lAddresses) { CService service(LookupNumeric(strAddNode.c_str(), Params().GetDefaultPort())); if (service.IsValid()) { // strAddNode is an IP:port @@ -1993,14 +1993,14 @@ void CConnman::ThreadMessageHandler() { LOCK(cs_vNodes); vNodesCopy = vNodes; - BOOST_FOREACH(CNode* pnode, vNodesCopy) { + for (CNode* pnode : vNodesCopy) { pnode->AddRef(); } } bool fMoreWork = false; - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) { if (pnode->fDisconnect) continue; @@ -2022,7 +2022,7 @@ void CConnman::ThreadMessageHandler() { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) pnode->Release(); } @@ -2150,7 +2150,7 @@ void Discover(boost::thread_group& threadGroup) std::vector vaddr; if (LookupHost(pszHostName, vaddr, 0, true)) { - 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()); @@ -2197,7 +2197,7 @@ void CConnman::SetNetworkActive(bool active) LOCK(cs_vNodes); // Close sockets to all nodes - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { pnode->CloseSocketDisconnect(); } } else { @@ -2399,18 +2399,18 @@ void CConnman::Stop() } // Close sockets - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) pnode->CloseSocketDisconnect(); - 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) { DeleteNode(pnode); } - BOOST_FOREACH(CNode *pnode, vNodesDisconnected) { + for (CNode *pnode : vNodesDisconnected) { DeleteNode(pnode); } vNodes.clear(); @@ -2722,7 +2722,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn fPauseSend = false; nProcessQueueSize = 0; - BOOST_FOREACH(const std::string &msg, getAllNetMessageTypes()) + for (const std::string &msg : getAllNetMessageTypes()) mapRecvBytesPerMsgCmd[msg] = 0; mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER] = 0; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 971db3427..7ec28ce2a 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -287,7 +287,7 @@ void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) { fUpdateConnectionTime = true; } - BOOST_FOREACH(const QueuedBlock& entry, state->vBlocksInFlight) { + for (const QueuedBlock& entry : state->vBlocksInFlight) { mapBlocksInFlight.erase(entry.hash); } EraseOrphansFor(nodeid); @@ -522,7 +522,7 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vectorIsValid(BLOCK_VALID_TREE)) { // We consider the chain that this peer is on invalid. return; @@ -566,7 +566,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); } @@ -627,7 +627,7 @@ bool AddOrphanTx(const CTransactionRef& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRE auto ret = mapOrphanTransactions.emplace(hash, COrphanTx{tx, peer, GetTime() + ORPHAN_TX_EXPIRE_TIME}); assert(ret.second); - BOOST_FOREACH(const CTxIn& txin, tx->vin) { + for (const CTxIn& txin : tx->vin) { mapOrphanTransactionsByPrev[txin.prevout].insert(ret.first); } @@ -643,7 +643,7 @@ int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) std::map::iterator it = mapOrphanTransactions.find(hash); if (it == mapOrphanTransactions.end()) return 0; - BOOST_FOREACH(const CTxIn& txin, it->second.tx->vin) + for (const CTxIn& txin : it->second.tx->vin) { auto itPrev = mapOrphanTransactionsByPrev.find(txin.prevout); if (itPrev == mapOrphanTransactionsByPrev.end()) @@ -768,7 +768,7 @@ void PeerLogicValidation::BlockConnected(const std::shared_ptr& pb // Erase orphan transactions include or precluded by this block if (vOrphanErase.size()) { int nErased = 0; - BOOST_FOREACH(uint256 &orphanHash, vOrphanErase) { + for (uint256 &orphanHash : vOrphanErase) { nErased += EraseOrphanTx(orphanHash); } LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased); @@ -1078,7 +1078,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam // 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) connman.PushMessage(pfrom, msgMaker.Make(SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::TX, *pblock->vtx[pair.first])); } // else @@ -1473,7 +1473,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr std::vector vAddrOk; int64_t nNow = GetAdjustedTime(); int64_t nSince = nNow - 10 * 60; - BOOST_FOREACH(CAddress& addr, vAddr) + for (CAddress& addr : vAddr) { if (interruptMsgProc) return true; @@ -1883,13 +1883,13 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } } - BOOST_FOREACH(uint256 hash, vEraseQueue) + for (uint256 hash : vEraseQueue) EraseOrphanTx(hash); } else if (fMissingInputs) { bool fRejectedParents = false; // It may be the case that the orphans parents have all been rejected - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { if (recentRejects->contains(txin.prevout.hash)) { fRejectedParents = true; break; @@ -1897,7 +1897,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } if (!fRejectedParents) { uint32_t nFetchFlags = GetFetchFlags(pfrom); - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { CInv _inv(MSG_TX | nFetchFlags, txin.prevout.hash); pfrom->AddInventoryKnown(_inv); if (!AlreadyHave(_inv)) pfrom->AskFor(_inv); @@ -2433,7 +2433,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr pfrom->vAddrToSend.clear(); std::vector vAddr = connman.GetAddresses(); FastRandomContext insecure_rand; - BOOST_FOREACH(const CAddress &addr, vAddr) + for (const CAddress &addr : vAddr) pfrom->PushAddress(addr, insecure_rand); } @@ -2627,7 +2627,7 @@ static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman& connman) AssertLockHeld(cs_main); CNodeState &state = *State(pnode->GetId()); - BOOST_FOREACH(const CBlockReject& reject, state.rejects) { + for (const CBlockReject& reject : state.rejects) { connman.PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, (std::string)NetMsgType::BLOCK, reject.chRejectCode, reject.strRejectReason, reject.hashBlock)); } state.rejects.clear(); @@ -2851,7 +2851,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& interr pto->nNextAddrSend = PoissonNextSend(nNow, AVG_ADDRESS_BROADCAST_INTERVAL); std::vector vAddr; vAddr.reserve(pto->vAddrToSend.size()); - BOOST_FOREACH(const CAddress& addr, pto->vAddrToSend) + for (const CAddress& addr : pto->vAddrToSend) { if (!pto->addrKnown.contains(addr.GetKey())) { @@ -2929,7 +2929,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& interr // Try to find first header that our peer doesn't have, and // then send all headers past that one. If we come across any // headers that aren't on chainActive, give up. - BOOST_FOREACH(const uint256 &hash, pto->vBlockHashesToAnnounce) { + for (const uint256 &hash : pto->vBlockHashesToAnnounce) { BlockMap::iterator mi = mapBlockIndex.find(hash); assert(mi != mapBlockIndex.end()); const CBlockIndex *pindex = mi->second; @@ -3055,7 +3055,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& interr vInv.reserve(std::max(pto->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX)); // Add blocks - BOOST_FOREACH(const uint256& hash, pto->vInventoryBlockToSend) { + for (const uint256& hash : pto->vInventoryBlockToSend) { vInv.push_back(CInv(MSG_BLOCK, hash)); if (vInv.size() == MAX_INV_SZ) { connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); @@ -3213,7 +3213,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& interr std::vector vToDownload; NodeId staller = -1; FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller, consensusParams); - BOOST_FOREACH(const CBlockIndex *pindex, vToDownload) { + for (const CBlockIndex *pindex : vToDownload) { uint32_t nFetchFlags = GetFetchFlags(pto); vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash())); MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex); diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index 14d58e744..5f68c09a8 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -111,7 +111,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes return false; } - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { // Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed // keys (remember the 520 byte limit on redeemScript size). That works @@ -132,7 +132,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes unsigned int nDataOut = 0; txnouttype whichType; - BOOST_FOREACH(const CTxOut& txout, tx.vout) { + for (const CTxOut& txout : tx.vout) { if (!::IsStandard(txout.scriptPubKey, whichType, witnessEnabled)) { reason = "scriptpubkey"; return false; diff --git a/src/policy/rbf.cpp b/src/policy/rbf.cpp index d9b47e71b..755ef83c9 100644 --- a/src/policy/rbf.cpp +++ b/src/policy/rbf.cpp @@ -6,7 +6,7 @@ bool SignalsOptInRBF(const CTransaction &tx) { - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { if (txin.nSequence < std::numeric_limits::max()-1) { return true; } @@ -38,7 +38,7 @@ RBFTransactionState IsRBFOptIn(const CTransaction &tx, CTxMemPool &pool) CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash()); pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false); - BOOST_FOREACH(CTxMemPool::txiter it, setAncestors) { + for (CTxMemPool::txiter it : setAncestors) { if (SignalsOptInRBF(it->GetTx())) { return RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125; } diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index 93120de1e..967933abf 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -81,7 +81,7 @@ public: 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()); diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 135cf6f70..2229ee888 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -452,7 +452,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(); @@ -628,7 +628,7 @@ void CoinControlDialog::updateView() std::map > mapCoins; model->listCoins(mapCoins); - BOOST_FOREACH(const PAIRTYPE(QString, std::vector)& coins, mapCoins) { + for (const PAIRTYPE(QString, std::vector)& coins : mapCoins) { CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem(); itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); QString sWalletAddress = coins.first; @@ -653,7 +653,7 @@ void CoinControlDialog::updateView() CAmount nSum = 0; int nChildren = 0; - BOOST_FOREACH(const COutput& out, coins.second) { + for (const COutput& out : coins.second) { nSum += out.tx->tx->vout[out.i].nValue; nChildren++; diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index fff072fd4..00dbcdce0 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -79,7 +79,7 @@ public: 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 dac397929..092314054 100644 --- a/src/qt/recentrequeststablemodel.cpp +++ b/src/qt/recentrequeststablemodel.cpp @@ -22,7 +22,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 233fc0877..8e8873637 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -133,7 +133,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco // Coinbase // CAmount nUnmatured = 0; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) nUnmatured += wallet->GetCredit(txout, ISMINE_ALL); strHTML += "" + tr("Credit") + ": "; if (wtx.IsInMainChain()) @@ -152,14 +152,14 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco else { isminetype fAllFromMe = ISMINE_SPENDABLE; - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) { isminetype mine = wallet->IsMine(txin); if(fAllFromMe > mine) fAllFromMe = mine; } isminetype fAllToMe = ISMINE_SPENDABLE; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) { isminetype mine = wallet->IsMine(txout); if(fAllToMe > mine) fAllToMe = mine; @@ -173,7 +173,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco // // Debit // - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) { // Ignore change isminetype toSelf = wallet->IsMine(txout); @@ -221,10 +221,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco // // Mixed debit transaction // - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) if (wallet->IsMine(txin)) strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "
"; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) if (wallet->IsMine(txout)) strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "
"; } @@ -276,10 +276,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco if (logCategories != BCLog::NONE) { strHTML += "

" + tr("Debug information") + "

"; - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) if(wallet->IsMine(txin)) strHTML += "" + tr("Debit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "
"; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) if(wallet->IsMine(txout)) strHTML += "" + tr("Credit") + ": " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "
"; @@ -289,7 +289,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco strHTML += "
" + tr("Inputs") + ":"; strHTML += "
    "; - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) { COutPoint prevout = txin.prevout; diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 0090b0c74..da070da08 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -78,7 +78,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet * { bool involvesWatchAddress = false; isminetype fAllFromMe = ISMINE_SPENDABLE; - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) { isminetype mine = wallet->IsMine(txin); if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; @@ -86,7 +86,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet * } isminetype fAllToMe = ISMINE_SPENDABLE; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) { isminetype mine = wallet->IsMine(txout); if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 8df0e481b..84f0fd3da 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -574,7 +574,7 @@ bool WalletModel::getPrivKey(const CKeyID &address, CKey& vchPrivKeyOut) 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(); diff --git a/src/rest.cpp b/src/rest.cpp index b08d7153b..8fb0c13fa 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -158,7 +158,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(); } @@ -178,7 +178,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)); } std::string strJSON = jsonHeaders.write() + "\n"; @@ -558,7 +558,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("height", (int32_t)coin.nHeight)); utxo.push_back(Pair("value", ValueFromAmount(coin.out.nValue))); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 96871ce1d..407fef14c 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -364,14 +364,14 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors())); const CTransaction& tx = e.GetTx(); std::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 std::string& dep, setDepends) + for (const std::string& dep : setDepends) { depends.push_back(dep); } @@ -385,7 +385,7 @@ UniValue mempoolToJSON(bool fVerbose) { LOCK(mempool.cs); UniValue o(UniValue::VOBJ); - BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) + for (const CTxMemPoolEntry& e : mempool.mapTx) { const uint256& hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); @@ -400,7 +400,7 @@ UniValue mempoolToJSON(bool fVerbose) 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; @@ -485,14 +485,14 @@ UniValue getmempoolancestors(const JSONRPCRequest& request) if (!fVerbose) { UniValue o(UniValue::VARR); - BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) { + for (CTxMemPool::txiter ancestorIt : setAncestors) { o.push_back(ancestorIt->GetTx().GetHash().ToString()); } return o; } else { UniValue o(UniValue::VOBJ); - BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) { + for (CTxMemPool::txiter ancestorIt : setAncestors) { const CTxMemPoolEntry &e = *ancestorIt; const uint256& _hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); @@ -549,14 +549,14 @@ UniValue getmempooldescendants(const JSONRPCRequest& request) if (!fVerbose) { UniValue o(UniValue::VARR); - BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) { + for (CTxMemPool::txiter descendantIt : setDescendants) { o.push_back(descendantIt->GetTx().GetHash().ToString()); } return o; } else { UniValue o(UniValue::VOBJ); - BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) { + for (CTxMemPool::txiter descendantIt : setDescendants) { const CTxMemPoolEntry &e = *descendantIt; const uint256& _hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); @@ -1256,7 +1256,7 @@ UniValue getchaintips(const JSONRPCRequest& request) std::set setOrphans; std::set setPrevs; - BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) + for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex) { if (!chainActive.Contains(item.second)) { setOrphans.insert(item.second); @@ -1276,7 +1276,7 @@ UniValue getchaintips(const JSONRPCRequest& request) /* 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)); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index d744269df..bdd84ee37 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -580,7 +580,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request) entry.push_back(Pair("hash", tx.GetWitnessHash().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 1f973a0c1..a9b28c31a 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -149,7 +149,7 @@ public: 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 10bf99eb3..1364ff990 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -126,7 +126,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request) 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); @@ -163,7 +163,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request) 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)); @@ -171,14 +171,14 @@ UniValue getpeerinfo(const JSONRPCRequest& request) obj.push_back(Pair("whitelisted", stats.fWhitelisted)); UniValue sendPerMsgCmd(UniValue::VOBJ); - BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapSendBytesPerMsgCmd) { + for (const mapMsgCmdSize::value_type &i : stats.mapSendBytesPerMsgCmd) { if (i.second > 0) sendPerMsgCmd.push_back(Pair(i.first, i.second)); } obj.push_back(Pair("bytessent_per_msg", sendPerMsgCmd)); UniValue recvPerMsgCmd(UniValue::VOBJ); - BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapRecvBytesPerMsgCmd) { + for (const mapMsgCmdSize::value_type &i : stats.mapRecvBytesPerMsgCmd) { if (i.second > 0) recvPerMsgCmd.push_back(Pair(i.first, i.second)); } @@ -474,7 +474,7 @@ UniValue getnetworkinfo(const JSONRPCRequest& request) 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())); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index e27c2a77c..945f11fde 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -282,7 +282,7 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()])) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain"); - BOOST_FOREACH(const uint256& hash, vMatch) + for (const uint256& hash : vMatch) res.push_back(hash.GetHex()); return res; } @@ -373,7 +373,7 @@ UniValue createrawtransaction(const JSONRPCRequest& request) std::set setAddress; std::vector addrList = sendTo.getKeys(); - BOOST_FOREACH(const std::string& name_, addrList) { + for (const std::string& name_ : addrList) { if (name_ == "data") { std::vector data = ParseHexV(sendTo[name_].getValStr(),"Data"); @@ -637,7 +637,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) 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) { view.AccessCoin(txin.prevout); // Load entries from viewChain into view; can fail. } @@ -781,7 +781,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata); // ... and merge in other signatures: - BOOST_FOREACH(const CMutableTransaction& txv, txVariants) { + for (const CMutableTransaction& txv : txVariants) { if (txv.vin.size() > i) { sigdata = CombineSignatures(prevPubKey, TransactionSignatureChecker(&txConst, i, amount), sigdata, DataFromTransaction(txv, i)); } diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index c5fbff007..48b2e4c27 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -64,7 +64,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; @@ -103,7 +103,7 @@ void RPCTypeCheckObj(const UniValue& o, if (fStrict) { - BOOST_FOREACH(const std::string& k, o.getKeys()) + for (const std::string& k : o.getKeys()) { if (typesExpected.count(k) == 0) { @@ -186,7 +186,7 @@ std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest& jreq.fHelp = true; jreq.params = UniValue(); - BOOST_FOREACH(const PAIRTYPE(std::string, const CRPCCommand*)& command, vCommands) + for (const PAIRTYPE(std::string, const CRPCCommand*)& command : vCommands) { const CRPCCommand *pcmd = command.second; std::string strMethod = pcmd->name; diff --git a/src/script/ismine.cpp b/src/script/ismine.cpp index a4743281b..35b534344 100644 --- a/src/script/ismine.cpp +++ b/src/script/ismine.cpp @@ -18,7 +18,7 @@ typedef std::vector valtype; unsigned int HaveKeys(const std::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)) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 568241854..91dc0f29d 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -126,7 +126,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP static CScript PushAll(const std::vector& values) { CScript result; - BOOST_FOREACH(const valtype& v, values) { + for (const valtype& v : values) { if (v.size() == 0) { result << OP_0; } else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) { @@ -232,12 +232,12 @@ static std::vector CombineMultisig(const CScript& scriptPubKey, const B { // Combine all the signatures we've got: std::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); @@ -248,7 +248,7 @@ static std::vector CombineMultisig(const CScript& scriptPubKey, const B unsigned int nSigsRequired = vSolutions.front()[0]; unsigned int nPubKeys = vSolutions.size()-2; std::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 63f20b099..85b33778b 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -94,7 +94,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::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/sync.cpp b/src/sync.cpp index 552682ab6..d32202b70 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -77,7 +77,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, { LogPrintf("POTENTIAL DEADLOCK DETECTED\n"); LogPrintf("Previous lock order was:\n"); - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s2) { + for (const PAIRTYPE(void*, CLockLocation) & i : s2) { if (i.first == mismatch.first) { LogPrintf(" (1)"); } @@ -87,7 +87,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, LogPrintf(" %s\n", i.second.ToString()); } LogPrintf("Current lock order is:\n"); - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s1) { + for (const PAIRTYPE(void*, CLockLocation) & i : s1) { if (i.first == mismatch.first) { LogPrintf(" (1)"); } @@ -108,7 +108,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry) (*lockstack).push_back(std::make_pair(c, locklocation)); - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, (*lockstack)) { + for (const PAIRTYPE(void*, CLockLocation) & i : (*lockstack)) { if (i.first == c) break; @@ -142,14 +142,14 @@ void LeaveCritical() std::string LocksHeld() { std::string result; - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, *lockstack) + for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) result += i.second.ToString() + std::string("\n"); return result; } void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) { - BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, *lockstack) + for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) if (i.first == cs) return; fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str()); diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp index c148ad6d8..6bcd550d7 100644 --- a/src/test/bip32_tests.cpp +++ b/src/test/bip32_tests.cpp @@ -93,7 +93,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/coins_tests.cpp b/src/test/coins_tests.cpp index 0ed71b96f..43b93c0c6 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test) found_an_entry = true; } } - BOOST_FOREACH(const CCoinsViewCacheTest *test, stack) { + for (const CCoinsViewCacheTest *test : stack) { test->SelfTest(); } } diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp index 9f59de3ef..01cc5ed83 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/multisig_tests.cpp b/src/test/multisig_tests.cpp index dd5678ea6..6d8aab887 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -28,7 +28,7 @@ sign_multisig(CScript scriptPubKey, std::vector keys, CTransaction transac CScript result; result << OP_0; // CHECKMULTISIG bug workaround - BOOST_FOREACH(const CKey &key, keys) + for (const CKey &key : keys) { std::vector vchSig; BOOST_CHECK(key.Sign(hash, vchSig)); diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index cfed5e347..cbc83b686 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -54,13 +54,13 @@ class prevector_tester { local_check(pretype(real_vector.begin(), real_vector.end()) == pre_vector); local_check(pretype(pre_vector.begin(), pre_vector.end()) == pre_vector); size_t pos = 0; - BOOST_FOREACH(const T& v, pre_vector) { + for (const T& v : pre_vector) { local_check(v == real_vector[pos++]); } BOOST_REVERSE_FOREACH(const T& v, pre_vector) { local_check(v == real_vector[--pos]); } - BOOST_FOREACH(const T& v, const_pre_vector) { + for (const T& v : const_pre_vector) { local_check(v == real_vector[pos++]); } BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) { diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 343c645cb..619560504 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -927,7 +927,7 @@ BOOST_AUTO_TEST_CASE(script_build) std::string strGen; - BOOST_FOREACH(TestBuilder& test, tests) { + for (TestBuilder& test : tests) { test.Test(); std::string str = JSONPrettyPrint(test.GetJSON()); #ifndef UPDATE_JSON_TESTS @@ -1033,7 +1033,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) { std::vector vchSig; BOOST_CHECK(key.Sign(hash, vchSig)); diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index cb625bda1..68d72a1bb 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -121,7 +121,7 @@ TestChain100Setup::CreateAndProcessBlock(const std::vector& // Replace mempool-selected txns with just coinbase plus passed-in txns: block.vtx.resize(1); - BOOST_FOREACH(const CMutableTransaction& tx, txns) + for (const CMutableTransaction& tx : txns) block.vtx.push_back(MakeTransactionRef(tx)); // IncrementExtraNonce creates a valid coinbase and merkleRoot unsigned int extraNonce = 0; diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 5c7516fbf..153473fb7 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -66,7 +66,7 @@ unsigned int ParseScriptFlags(std::string strFlags) std::vector words; boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(",")); - BOOST_FOREACH(std::string word, words) + for (std::string word : words) { if (!mapFlagNames.count(word)) BOOST_ERROR("Bad test: unknown verification flag '" << word << "'"); @@ -394,7 +394,7 @@ void CheckWithFlag(const CTransactionRef& output, const CMutableTransaction& inp static CScript PushAll(const std::vector& values) { CScript result; - BOOST_FOREACH(const valtype& v, values) { + for (const valtype& v : values) { if (v.size() == 0) { result << OP_0; } else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) { diff --git a/src/timedata.cpp b/src/timedata.cpp index ec7491270..d736baa21 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -95,7 +95,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) { // 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; @@ -110,7 +110,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) } if (LogAcceptCategory(BCLog::NET)) { - BOOST_FOREACH(int64_t n, vSorted) { + for (int64_t n : vSorted) { LogPrint(BCLog::NET, "%+d ", n); } LogPrint(BCLog::NET, "| "); diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 8a37139f1..f069cc7f1 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -487,7 +487,7 @@ void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlRe { if (reply.code == 250) { LogPrint(BCLog::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()) @@ -617,7 +617,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); @@ -634,7 +634,7 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro } } } - BOOST_FOREACH(const std::string &s, methods) { + for (const std::string &s : methods) { LogPrint(BCLog::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 17389db9f..afafc695f 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -73,12 +73,12 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendan setAllDescendants.insert(cit); stageEntries.erase(cit); const setEntries &setChildren = GetMemPoolChildren(cit); - BOOST_FOREACH(const txiter childEntry, setChildren) { + for (const txiter childEntry : setChildren) { cacheMap::iterator cacheIt = cachedDescendants.find(childEntry); if (cacheIt != cachedDescendants.end()) { // We've already calculated this one, just add the entries for this set // but don't traverse again. - BOOST_FOREACH(const txiter cacheEntry, cacheIt->second) { + for (const txiter cacheEntry : cacheIt->second) { setAllDescendants.insert(cacheEntry); } } else if (!setAllDescendants.count(childEntry)) { @@ -92,7 +92,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendan int64_t modifySize = 0; CAmount modifyFee = 0; int64_t modifyCount = 0; - BOOST_FOREACH(txiter cit, setAllDescendants) { + for (txiter cit : setAllDescendants) { if (!setExclude.count(cit->GetTx().GetHash())) { modifySize += cit->GetTxSize(); modifyFee += cit->GetModifiedFee(); @@ -202,7 +202,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntr } const setEntries & setMemPoolParents = GetMemPoolParents(stageit); - BOOST_FOREACH(const txiter &phash, setMemPoolParents) { + for (const txiter &phash : setMemPoolParents) { // If this is a new ancestor, add it. if (setAncestors.count(phash) == 0) { parentHashes.insert(phash); @@ -221,13 +221,13 @@ void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors { setEntries parentIters = GetMemPoolParents(it); // add or remove this tx as a child of each parent - BOOST_FOREACH(txiter piter, parentIters) { + for (txiter piter : parentIters) { UpdateChild(piter, it, add); } const int64_t updateCount = (add ? 1 : -1); const int64_t updateSize = updateCount * it->GetTxSize(); const CAmount updateFee = updateCount * it->GetModifiedFee(); - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { mapTx.modify(ancestorIt, update_descendant_state(updateSize, updateFee, updateCount)); } } @@ -238,7 +238,7 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto int64_t updateSize = 0; CAmount updateFee = 0; int64_t updateSigOpsCost = 0; - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { updateSize += ancestorIt->GetTxSize(); updateFee += ancestorIt->GetModifiedFee(); updateSigOpsCost += ancestorIt->GetSigOpCost(); @@ -249,7 +249,7 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto void CTxMemPool::UpdateChildrenForRemoval(txiter it) { const setEntries &setMemPoolChildren = GetMemPoolChildren(it); - BOOST_FOREACH(txiter updateIt, setMemPoolChildren) { + for (txiter updateIt : setMemPoolChildren) { UpdateParent(updateIt, it, false); } } @@ -266,19 +266,19 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b // Here we only update statistics and not data in mapLinks (which // we need to preserve until we're finished with all operations that // need to traverse the mempool). - BOOST_FOREACH(txiter removeIt, entriesToRemove) { + for (txiter removeIt : entriesToRemove) { setEntries setDescendants; CalculateDescendants(removeIt, setDescendants); setDescendants.erase(removeIt); // don't update state for self int64_t modifySize = -((int64_t)removeIt->GetTxSize()); CAmount modifyFee = -removeIt->GetModifiedFee(); int modifySigOps = -removeIt->GetSigOpCost(); - BOOST_FOREACH(txiter dit, setDescendants) { + for (txiter dit : setDescendants) { mapTx.modify(dit, update_ancestor_state(modifySize, modifyFee, -1, modifySigOps)); } } } - BOOST_FOREACH(txiter removeIt, entriesToRemove) { + for (txiter removeIt : entriesToRemove) { setEntries setAncestors; const CTxMemPoolEntry &entry = *removeIt; std::string dummy; @@ -307,7 +307,7 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b // After updating all the ancestor sizes, we can now sever the link between each // transaction being removed and any mempool children (ie, update setMemPoolParents // for each direct child of a transaction being removed). - BOOST_FOREACH(txiter removeIt, entriesToRemove) { + for (txiter removeIt : entriesToRemove) { UpdateChildrenForRemoval(removeIt); } } @@ -401,7 +401,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, // to clean up the mess we're leaving here. // Update ancestors with information about this tx - BOOST_FOREACH (const uint256 &phash, setParentTransactions) { + for (const uint256 &phash : setParentTransactions) { txiter pit = mapTx.find(phash); if (pit != mapTx.end()) { UpdateParent(newit, pit, true); @@ -424,7 +424,7 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) { NotifyEntryRemoved(it->GetSharedTx(), reason); const uint256 hash = it->GetTx().GetHash(); - BOOST_FOREACH(const CTxIn& txin, it->GetTx().vin) + for (const CTxIn& txin : it->GetTx().vin) mapNextTx.erase(txin.prevout); if (vTxHashes.size() > 1) { @@ -466,7 +466,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries &setDescendants stage.erase(it); const setEntries &setChildren = GetMemPoolChildren(it); - BOOST_FOREACH(const txiter &childiter, setChildren) { + for (const txiter &childiter : setChildren) { if (!setDescendants.count(childiter)) { stage.insert(childiter); } @@ -498,7 +498,7 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReaso } } setEntries setAllRemoves; - BOOST_FOREACH(txiter it, txToRemove) { + for (txiter it : txToRemove) { CalculateDescendants(it, setAllRemoves); } @@ -520,7 +520,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem // So it's critical that we remove the tx and not depend on the LockPoints. txToRemove.insert(it); } else if (it->GetSpendsCoinbase()) { - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash); if (it2 != mapTx.end()) continue; @@ -547,7 +547,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx) { // Remove transactions which depend on inputs of tx, recursively LOCK(cs); - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { auto it = mapNextTx.find(txin.prevout); if (it != mapNextTx.end()) { const CTransaction &txConflict = *it->second; @@ -642,7 +642,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const setEntries setParentCheck; int64_t parentSizes = 0; int64_t parentSigOpCost = 0; - 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. indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash); if (it2 != mapTx.end()) { @@ -674,7 +674,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const CAmount nFeesCheck = it->GetModifiedFee(); int64_t nSigOpCheck = it->GetSigOpCost(); - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { nSizeCheck += ancestorIt->GetTxSize(); nFeesCheck += ancestorIt->GetModifiedFee(); nSigOpCheck += ancestorIt->GetSigOpCost(); @@ -848,14 +848,14 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD uint64_t nNoLimit = std::numeric_limits::max(); std::string dummy; CalculateMemPoolAncestors(*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy, false); - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { mapTx.modify(ancestorIt, update_descendant_state(0, nFeeDelta, 0)); } // Now update all descendants' modified fees with ancestors setEntries setDescendants; CalculateDescendants(it, setDescendants); setDescendants.erase(it); - BOOST_FOREACH(txiter descendantIt, setDescendants) { + for (txiter descendantIt : setDescendants) { mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0)); } ++nTransactionsUpdated; @@ -919,7 +919,7 @@ size_t CTxMemPool::DynamicMemoryUsage() const { void CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) { AssertLockHeld(cs); UpdateForRemoveFromMempool(stage, updateDescendants); - BOOST_FOREACH(const txiter& it, stage) { + for (const txiter& it : stage) { removeUnchecked(it, reason); } } @@ -933,7 +933,7 @@ int CTxMemPool::Expire(int64_t time) { it++; } setEntries stage; - BOOST_FOREACH(txiter removeit, toremove) { + for (txiter removeit : toremove) { CalculateDescendants(removeit, stage); } RemoveStaged(stage, false, MemPoolRemovalReason::EXPIRY); @@ -1042,13 +1042,13 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector* pvNoSpends std::vector txn; if (pvNoSpendsRemaining) { txn.reserve(stage.size()); - BOOST_FOREACH(txiter iter, stage) + for (txiter iter : stage) txn.push_back(iter->GetTx()); } RemoveStaged(stage, false, MemPoolRemovalReason::SIZELIMIT); if (pvNoSpendsRemaining) { - BOOST_FOREACH(const CTransaction& tx, txn) { - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTransaction& tx : txn) { + for (const CTxIn& txin : tx.vin) { if (exists(txin.prevout.hash)) continue; if (!mapNextTx.count(txin.prevout)) { pvNoSpendsRemaining->push_back(txin.prevout); diff --git a/src/validation.cpp b/src/validation.cpp index de65839ee..ddedbdb97 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -160,7 +160,7 @@ namespace { 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()) { @@ -297,7 +297,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp, bool // lock on a mempool input, so we can use the return value of // CheckSequenceLocks to indicate the LockPoints validity int maxInputHeight = 0; - BOOST_FOREACH(int height, prevheights) { + for (int height : prevheights) { // Can ignore mempool inputs since we'll fail if they had non-zero locks if (height != tip->nHeight+1) { maxInputHeight = std::max(maxInputHeight, height); @@ -317,7 +317,7 @@ void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age) { std::vector vNoSpendsRemaining; pool.TrimToSize(limit, &vNoSpendsRemaining); - BOOST_FOREACH(const COutPoint& removed, vNoSpendsRemaining) + for (const COutPoint& removed : vNoSpendsRemaining) pcoinsTip->Uncache(removed); } @@ -434,7 +434,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C std::set setConflicts; { LOCK(pool.cs); // protect pool.mapNextTx - BOOST_FOREACH(const CTxIn &txin, tx.vin) + for (const CTxIn &txin : tx.vin) { auto itConflicting = pool.mapNextTx.find(txin.prevout); if (itConflicting != pool.mapNextTx.end()) @@ -457,7 +457,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C bool fReplacementOptOut = true; if (fEnableReplacement) { - BOOST_FOREACH(const CTxIn &_txin, ptxConflicting->vin) + for (const CTxIn &_txin : ptxConflicting->vin) { if (_txin.nSequence < std::numeric_limits::max()-1) { @@ -499,7 +499,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C } // do all inputs exist? - BOOST_FOREACH(const CTxIn txin, tx.vin) { + for (const CTxIn txin : tx.vin) { if (!pcoinsTip->HaveCoinInCache(txin.prevout)) { coins_to_uncache.push_back(txin.prevout); } @@ -547,7 +547,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C // Keep track of transactions that spend a coinbase, which we re-scan // during reorgs to ensure COINBASE_MATURITY is still met. bool fSpendsCoinbase = false; - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { const Coin &coin = view.AccessCoin(txin.prevout); if (coin.IsCoinBase()) { fSpendsCoinbase = true; @@ -598,7 +598,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C // that we have the set of all ancestors we can detect this // pathological case by making sure setConflicts and setAncestors don't // intersect. - BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) + for (CTxMemPool::txiter ancestorIt : setAncestors) { const uint256 &hashAncestor = ancestorIt->GetTx().GetHash(); if (setConflicts.count(hashAncestor)) @@ -629,7 +629,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C std::set setConflictsParents; const int maxDescendantsToVisit = 100; CTxMemPool::setEntries setIterConflicting; - BOOST_FOREACH(const uint256 &hashConflicting, setConflicts) + for (const uint256 &hashConflicting : setConflicts) { CTxMemPool::txiter mi = pool.mapTx.find(hashConflicting); if (mi == pool.mapTx.end()) @@ -665,7 +665,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C oldFeeRate.ToString())); } - BOOST_FOREACH(const CTxIn &txin, mi->GetTx().vin) + for (const CTxIn &txin : mi->GetTx().vin) { setConflictsParents.insert(txin.prevout.hash); } @@ -678,10 +678,10 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C if (nConflictingCount <= maxDescendantsToVisit) { // If not too many to replace, then calculate the set of // transactions that would have to be evicted - BOOST_FOREACH(CTxMemPool::txiter it, setIterConflicting) { + for (CTxMemPool::txiter it : setIterConflicting) { pool.CalculateDescendants(it, allConflicting); } - BOOST_FOREACH(CTxMemPool::txiter it, allConflicting) { + for (CTxMemPool::txiter it : allConflicting) { nConflictingFees += it->GetModifiedFee(); nConflictingSize += it->GetTxSize(); } @@ -775,7 +775,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C } // Remove conflicting transactions from the mempool - BOOST_FOREACH(const CTxMemPool::txiter it, allConflicting) + for (const CTxMemPool::txiter it : allConflicting) { LogPrint(BCLog::MEMPOOL, "replacing tx %s with %s for %s BTC additional fees, %d delta bytes\n", it->GetTx().GetHash().ToString(), @@ -816,7 +816,7 @@ bool AcceptToMemoryPoolWithTime(CTxMemPool& pool, CValidationState &state, const std::vector coins_to_uncache; bool res = AcceptToMemoryPoolWorker(pool, state, tx, fLimitFree, pfMissingInputs, nAcceptTime, plTxnReplaced, fOverrideMempoolLimit, nAbsurdFee, coins_to_uncache); if (!res) { - BOOST_FOREACH(const COutPoint& hashTx, coins_to_uncache) + for (const COutPoint& hashTx : coins_to_uncache) pcoinsTip->Uncache(hashTx); } // After we've (potentially) uncached entries, ensure our coins cache is still within its size limits @@ -1116,7 +1116,7 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund // mark inputs spent if (!tx.IsCoinBase()) { txundo.vprevout.reserve(tx.vin.size()); - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { txundo.vprevout.emplace_back(); inputs.SpendCoin(txin.prevout, &txundo.vprevout.back()); } @@ -3097,7 +3097,7 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, uint64_t CalculateCurrentUsage() { uint64_t retval = 0; - BOOST_FOREACH(const CBlockFileInfo &file, vinfoBlockFile) { + for (const CBlockFileInfo &file : vinfoBlockFile) { retval += file.nSize + file.nUndoSize; } return retval; @@ -3300,13 +3300,13 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) // Calculate nChainWork std::vector > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); - BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) + for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) { CBlockIndex* pindex = item.second; vSortedByHeight.push_back(std::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); @@ -3355,7 +3355,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) // Check presence of blk files LogPrintf("Checking all blk files are present...\n"); std::set setBlkDataFiles; - BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) + for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) { CBlockIndex* pindex = item.second; if (pindex->nStatus & BLOCK_HAVE_DATA) { @@ -3611,7 +3611,7 @@ void UnloadBlockIndex() warningcache[b].clear(); } - BOOST_FOREACH(BlockMap::value_type& entry, mapBlockIndex) { + for (BlockMap::value_type& entry : mapBlockIndex) { delete entry.second; } mapBlockIndex.clear(); diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp index fc318c161..836c15b82 100644 --- a/src/wallet/crypter.cpp +++ b/src/wallet/crypter.cpp @@ -285,7 +285,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(); diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 25f6bdd9d..af8677c02 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -205,7 +205,7 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco } DbTxn* ptxn = bitdb.TxnBegin(); - BOOST_FOREACH(CDBEnv::KeyValPair& row, salvagedData) + for (CDBEnv::KeyValPair& row : salvagedData) { if (recoverKVcallback) { diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 457e937bb..c2abd2213 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -48,7 +48,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 { @@ -1106,7 +1106,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest) UniValue response(UniValue::VARR); - BOOST_FOREACH (const UniValue& data, requests.getValues()) { + for (const UniValue& data : requests.getValues()) { const int64_t timestamp = std::max(GetImportTimestamp(data, now), minimumTimestamp); const UniValue result = ProcessImport(pwallet, data, timestamp); response.push_back(result); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3b6dfd42c..cfc9ee5c1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -78,7 +78,7 @@ 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())); @@ -96,7 +96,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) } entry.push_back(Pair("bip125-replaceable", rbfStatus)); - BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item, wtx.mapValue) + for (const PAIRTYPE(std::string, std::string)& item : wtx.mapValue) entry.push_back(Pair(item.first, item.second)); } @@ -490,7 +490,7 @@ UniValue listaddressgroupings(const JSONRPCRequest& request) std::map balances = pwallet->GetAddressBalances(); for (std::set grouping : pwallet->GetAddressGroupings()) { UniValue jsonGrouping(UniValue::VARR); - BOOST_FOREACH(CTxDestination address, grouping) + for (CTxDestination address : grouping) { UniValue addressInfo(UniValue::VARR); addressInfo.push_back(CBitcoinAddress(address).ToString()); @@ -616,7 +616,7 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request) if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx)) continue; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) if (txout.scriptPubKey == scriptPubKey) if (wtx.GetDepthInMainChain() >= nMinDepth) nAmount += txout.nValue; @@ -671,7 +671,7 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request) if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx)) continue; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) { CTxDestination address; if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwallet, address) && setAddress.count(address)) { @@ -950,7 +950,7 @@ UniValue sendmany(const JSONRPCRequest& request) CAmount totalAmount = 0; std::vector keys = sendTo.getKeys(); - BOOST_FOREACH(const std::string& name_, keys) + for (const std::string& name_ : keys) { CBitcoinAddress address(name_); if (!address.IsValid()) @@ -1191,7 +1191,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA if (nDepth < nMinDepth) continue; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) { CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address)) @@ -1251,7 +1251,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA 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()); } @@ -1385,7 +1385,7 @@ void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const std::s // 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(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) { @@ -1410,7 +1410,7 @@ void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const std::s // Received if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) { - BOOST_FOREACH(const COutputEntry& r, listReceived) + for (const COutputEntry& r : listReceived) { std::string account; if (pwallet->mapAddressBook.count(r.destination)) { @@ -1655,11 +1655,11 @@ UniValue listaccounts(const JSONRPCRequest& request) 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 (pwallet->mapAddressBook.count(r.destination)) { mapAccountBalances[pwallet->mapAddressBook[r.destination].name] += r.amount; } @@ -1669,11 +1669,11 @@ UniValue listaccounts(const JSONRPCRequest& request) } const std::list& acentries = pwallet->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(std::string, CAmount)& accountBalance, mapAccountBalances) { + for (const PAIRTYPE(std::string, CAmount)& accountBalance : mapAccountBalances) { ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); } return ret; @@ -2338,7 +2338,7 @@ UniValue listlockunspent(const JSONRPCRequest& request) 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())); @@ -2456,7 +2456,7 @@ UniValue resendwallettransactions(const JSONRPCRequest& request) std::vector txids = pwallet->ResendWalletTransactionsBefore(GetTime(), g_connman.get()); UniValue result(UniValue::VARR); - BOOST_FOREACH(const uint256& txid, txids) + for (const uint256& txid : txids) { result.push_back(txid.ToString()); } @@ -2581,7 +2581,7 @@ UniValue listunspent(const JSONRPCRequest& request) LOCK2(cs_main, pwallet->cs_wallet); pwallet->AvailableCoins(vecOutputs, !include_unsafe, NULL, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, nMinDepth, nMaxDepth); - BOOST_FOREACH(const COutput& out, vecOutputs) { + for (const COutput& out : vecOutputs) { CTxDestination address; const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey; bool fValidAddress = ExtractDestination(scriptPubKey, address); diff --git a/src/wallet/test/accounting_tests.cpp b/src/wallet/test/accounting_tests.cpp index 1fe633f2e..12d9f2e99 100644 --- a/src/wallet/test/accounting_tests.cpp +++ b/src/wallet/test/accounting_tests.cpp @@ -23,7 +23,7 @@ GetResults(std::map& results) results.clear(); BOOST_CHECK(pwalletMain->ReorderTransactions() == DB_LOAD_OK); pwalletMain->ListAccountCreditDebit("", aes); - BOOST_FOREACH(CAccountingEntry& ae, aes) + for (CAccountingEntry& ae : aes) { results[ae.nOrderPos] = ae; } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3e000d2a9..531a1fabf 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -297,7 +297,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase) { 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; @@ -320,7 +320,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(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; @@ -412,7 +412,7 @@ std::set CWallet::GetConflicts(const uint256& txid) const std::pair range; - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) { if (mapTxSpends.count(txin.prevout) <= 1) continue; // No conflict if zero or one spends @@ -544,7 +544,7 @@ void CWallet::AddToSpends(const uint256& wtxid) if (thisTx.IsCoinBase()) // Coinbases don't spend anything! return; - BOOST_FOREACH(const CTxIn& txin, thisTx.tx->vin) + for (const CTxIn& txin : thisTx.tx->vin) AddToSpends(txin.prevout, wtxid); } @@ -659,7 +659,7 @@ DBErrors CWallet::ReorderTransactions() } std::list acentries; walletdb.ListAccountCreditDebit("", acentries); - BOOST_FOREACH(CAccountingEntry& entry, acentries) + for (CAccountingEntry& entry : acentries) { txByTime.insert(std::make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); } @@ -689,7 +689,7 @@ DBErrors CWallet::ReorderTransactions() else { int64_t nOrderPosOff = 0; - BOOST_FOREACH(const int64_t& nOffsetStart, nOrderPosOffsets) + for (const int64_t& nOffsetStart : nOrderPosOffsets) { if (nOrderPos >= nOffsetStart) ++nOrderPosOff; @@ -778,7 +778,7 @@ bool CWallet::GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bFo for (std::map::iterator it = mapWallet.begin(); it != mapWallet.end() && account.vchPubKey.IsValid(); ++it) - BOOST_FOREACH(const CTxOut& txout, (*it).second.tx->vout) + for (const CTxOut& txout : (*it).second.tx->vout) if (txout.scriptPubKey == scriptPubKey) { bForceNew = true; break; @@ -804,7 +804,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(); } } @@ -922,7 +922,7 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn) wtx.BindWallet(this); wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0))); AddToSpends(hash); - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) { + for (const CTxIn& txin : wtx.tx->vin) { if (mapWallet.count(txin.prevout.hash)) { CWalletTx& prevtx = mapWallet[txin.prevout.hash]; if (prevtx.nIndex == -1 && !prevtx.hashUnset()) { @@ -954,7 +954,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const CBlockI AssertLockHeld(cs_wallet); if (pIndex != NULL) { - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { std::pair range = mapTxSpends.equal_range(txin.prevout); while (range.first != range.second) { if (range.first->second != tx.GetHash()) { @@ -1035,7 +1035,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx) } // If a transaction changes 'conflicted' state, that changes the balance // available of the outputs it spends. So force those to be recomputed - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) { if (mapWallet.count(txin.prevout.hash)) mapWallet[txin.prevout.hash].MarkDirty(); @@ -1096,7 +1096,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx) } // If a transaction changes 'conflicted' state, that changes the balance // available of the outputs it spends. So force those to be recomputed - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) { if (mapWallet.count(txin.prevout.hash)) mapWallet[txin.prevout.hash].MarkDirty(); @@ -1114,7 +1114,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pin // 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 (mapWallet.count(txin.prevout.hash)) mapWallet[txin.prevout.hash].MarkDirty(); @@ -1230,7 +1230,7 @@ CAmount CWallet::GetChange(const CTxOut& txout) const bool CWallet::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; @@ -1244,7 +1244,7 @@ bool CWallet::IsFromMe(const CTransaction& tx) const CAmount CWallet::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)) @@ -1257,7 +1257,7 @@ bool CWallet::IsAllFromMe(const CTransaction& tx, const isminefilter& filter) co { LOCK(cs_wallet); - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) { auto mi = mapWallet.find(txin.prevout.hash); if (mi == mapWallet.end()) @@ -1277,7 +1277,7 @@ bool CWallet::IsAllFromMe(const CTransaction& tx, const isminefilter& filter) co CAmount CWallet::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)) @@ -1289,7 +1289,7 @@ CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) c CAmount CWallet::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)) @@ -1525,7 +1525,7 @@ void CWallet::ReacceptWalletTransactions() std::map mapSorted; // Sort pending wallet transactions based on their initial wallet insertion order - BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) + for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) { const uint256& wtxid = item.first; CWalletTx& wtx = item.second; @@ -1539,7 +1539,7 @@ void CWallet::ReacceptWalletTransactions() } // Try to add wallet transactions to memory pool - BOOST_FOREACH(PAIRTYPE(const int64_t, CWalletTx*)& item, mapSorted) + for (PAIRTYPE(const int64_t, CWalletTx*)& item : mapSorted) { CWalletTx& wtx = *(item.second); @@ -1767,7 +1767,7 @@ bool CWalletTx::IsTrusted() const return false; // Trusted if all inputs are from us and are in the mempool: - BOOST_FOREACH(const CTxIn& txin, tx->vin) + for (const CTxIn& txin : tx->vin) { // Transactions not sent by us: not trusted const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash); @@ -1796,7 +1796,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon LOCK(cs_wallet); // Sort them in chronological order std::multimap mapSorted; - BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) + for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) { CWalletTx& wtx = item.second; // Don't rebroadcast if newer than nTime: @@ -1804,7 +1804,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon continue; mapSorted.insert(std::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; if (wtx.RelayWalletTransaction(connman)) @@ -2228,7 +2228,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); - BOOST_FOREACH(const COutput &output, vCoins) + for (const COutput &output : vCoins) { if (!output.fSpendable) continue; @@ -2328,7 +2328,7 @@ bool CWallet::SelectCoins(const std::vector& vAvailableCoins, const CAm // coin control -> return all selected outputs (we want all selected to go into the transaction for sure) if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs) { - BOOST_FOREACH(const COutput& out, vCoins) + for (const COutput& out : vCoins) { if (!out.fSpendable) continue; @@ -2345,7 +2345,7 @@ bool CWallet::SelectCoins(const std::vector& vAvailableCoins, const CAm std::vector vPresetInputs; if (coinControl) coinControl->ListSelected(vPresetInputs); - BOOST_FOREACH(const COutPoint& outpoint, vPresetInputs) + for (const COutPoint& outpoint : vPresetInputs) { std::map::const_iterator it = mapWallet.find(outpoint.hash); if (it != mapWallet.end()) @@ -2433,7 +2433,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool ov coinControl.fOverrideFeeRate = overrideEstimatedFeeRate; coinControl.nFeeRate = specificFeeRate; - BOOST_FOREACH(const CTxIn& txin, tx.vin) + for (const CTxIn& txin : tx.vin) coinControl.Select(txin.prevout); CReserveKey reservekey(this); @@ -2449,7 +2449,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool ov tx.vout[idx].nValue = wtx.tx->vout[idx].nValue; // Add new txins (keeping original txin scriptSig/order) - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) { if (!coinControl.IsSelected(txin.prevout)) { @@ -2832,7 +2832,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon AddToWallet(wtxNew); // Notify that old coins are spent - BOOST_FOREACH(const CTxIn& txin, wtxNew.tx->vin) + for (const CTxIn& txin : wtxNew.tx->vin) { CWalletTx &coin = mapWallet[txin.prevout.hash]; coin.BindWallet(this); @@ -3010,7 +3010,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address) // Delete destdata tuples associated with address std::string strAddress = CBitcoinAddress(address).ToString(); - BOOST_FOREACH(const PAIRTYPE(std::string, std::string) &item, mapAddressBook[address].destdata) + for (const PAIRTYPE(std::string, std::string) &item : mapAddressBook[address].destdata) { CWalletDB(*dbw).EraseDestData(strAddress, item.first); } @@ -3055,7 +3055,7 @@ bool CWallet::NewKeyPool() { LOCK(cs_wallet); CWalletDB walletdb(*dbw); - BOOST_FOREACH(int64_t nIndex, setKeyPool) + for (int64_t nIndex : setKeyPool) walletdb.ErasePool(nIndex); setKeyPool.clear(); @@ -3305,7 +3305,7 @@ std::set< std::set > CWallet::GetAddressGroupings() { bool any_mine = false; // group all input addresses with each other - BOOST_FOREACH(CTxIn txin, pcoin->tx->vin) + for (CTxIn txin : pcoin->tx->vin) { CTxDestination address; if(!IsMine(txin)) /* If this input isn't mine, ignore it */ @@ -3319,7 +3319,7 @@ std::set< std::set > CWallet::GetAddressGroupings() // group change with input addresses if (any_mine) { - BOOST_FOREACH(CTxOut txout, pcoin->tx->vout) + for (CTxOut txout : pcoin->tx->vout) if (IsChange(txout)) { CTxDestination txoutAddr; @@ -3350,18 +3350,18 @@ std::set< std::set > CWallet::GetAddressGroupings() std::set< std::set* > uniqueGroupings; // a set of pointers to groups of addresses std::map< CTxDestination, std::set* > setmap; // map addresses to the unique group containing it - BOOST_FOREACH(std::set _grouping, groupings) + for (std::set _grouping : groupings) { // make a set of all the groups hit by this new group std::set< std::set* > hits; std::map< CTxDestination, std::set* >::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 std::set* merged = new std::set(_grouping); - BOOST_FOREACH(std::set* hit, hits) + for (std::set* hit : hits) { merged->insert(hit->begin(), hit->end()); uniqueGroupings.erase(hit); @@ -3370,12 +3370,12 @@ std::set< std::set > CWallet::GetAddressGroupings() uniqueGroupings.insert(merged); // update setmap - BOOST_FOREACH(CTxDestination element, *merged) + for (CTxDestination element : *merged) setmap[element] = merged; } std::set< std::set > ret; - BOOST_FOREACH(std::set* uniqueGrouping, uniqueGroupings) + for (std::set* uniqueGrouping : uniqueGroupings) { ret.insert(*uniqueGrouping); delete uniqueGrouping; @@ -3388,7 +3388,7 @@ std::set CWallet::GetAccountAddresses(const std::string& strAcco { LOCK(cs_wallet); std::set result; - BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, mapAddressBook) + for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : mapAddressBook) { const CTxDestination& address = item.first; const std::string& strName = item.second.name; @@ -3438,7 +3438,7 @@ void CWallet::GetAllReserveKeys(std::set& setAddress) const CWalletDB walletdb(*dbw); 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)) @@ -3513,7 +3513,7 @@ public: 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); } } @@ -3548,7 +3548,7 @@ void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) c 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; } @@ -3567,10 +3567,10 @@ void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) c 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.tx->vout) { + for (const CTxOut &txout : wtx.tx->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) @@ -3891,7 +3891,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile) { CWalletDB walletdb(*walletInstance->dbw); - BOOST_FOREACH(const CWalletTx& wtxOld, vWtx) + for (const CWalletTx& wtxOld : vWtx) { uint256 hash = wtxOld.GetHash(); std::map::iterator mi = walletInstance->mapWallet.find(hash); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 342c797dd..bce6dc8d7 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -208,7 +208,7 @@ CAmount CWalletDB::GetAccountCreditDebit(const std::string& strAccount) ListAccountCreditDebit(strAccount, entries); CAmount nCreditDebit = 0; - BOOST_FOREACH (const CAccountingEntry& entry, entries) + for (const CAccountingEntry& entry : entries) nCreditDebit += entry.nCreditDebit; return nCreditDebit; @@ -635,7 +635,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) if ((wss.nKeys + wss.nCKeys + wss.nWatchKeys) != wss.nKeyMeta) pwallet->UpdateTimeFirstKey(1); - BOOST_FOREACH(uint256 hash, wss.vWalletUpgrade) + for (uint256 hash : wss.vWalletUpgrade) WriteTx(pwallet->mapWallet[hash]); // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: @@ -650,7 +650,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))); } @@ -736,7 +736,7 @@ DBErrors CWalletDB::ZapSelectTx(std::vector& vTxHashIn, std::vector::iterator it = vTxHashIn.begin(); - BOOST_FOREACH (uint256 hash, vTxHash) { + for (uint256 hash : vTxHash) { while (it < vTxHashIn.end() && (*it) < hash) { it++; } @@ -767,7 +767,7 @@ DBErrors CWalletDB::ZapWalletTx(std::vector& vWtx) return err; // erase each wallet TX - BOOST_FOREACH (uint256& hash, vTxHash) { + for (uint256& hash : vTxHash) { if (!EraseTx(hash)) return DB_CORRUPT; } From 18dc3c396299caccb0df31254aaec0d08b70dd2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Fri, 2 Jun 2017 03:25:02 +0200 Subject: [PATCH 3/4] scripted-diff: Remove Q_FOREACH -BEGIN VERIFY SCRIPT- sed -i 's/Q_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; -END VERIFY SCRIPT- --- src/qt/addressbookpage.cpp | 2 +- src/qt/bitcoingui.cpp | 6 +++--- src/qt/coincontroldialog.cpp | 2 +- src/qt/optionsdialog.cpp | 2 +- src/qt/paymentserver.cpp | 10 +++++----- src/qt/peertablemodel.cpp | 4 ++-- src/qt/platformstyle.cpp | 2 +- src/qt/receivecoinsdialog.cpp | 2 +- src/qt/sendcoinsdialog.cpp | 4 ++-- src/qt/splashscreen.cpp | 2 +- src/qt/test/paymentservertests.cpp | 2 +- src/qt/trafficgraphwidget.cpp | 4 ++-- src/qt/transactiondesc.cpp | 4 ++-- src/qt/transactiontablemodel.cpp | 2 +- src/qt/utilitydialog.cpp | 2 +- src/qt/walletmodel.cpp | 6 +++--- src/qt/walletmodeltransaction.cpp | 2 +- 17 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index b1253a9f1..cebac46b9 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -254,7 +254,7 @@ void AddressBookPage::done(int retval) // Figure out which address was selected, and return it QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); - Q_FOREACH (const QModelIndex& index, indexes) { + for (const QModelIndex& index : indexes) { QVariant address = table->model()->data(index); returnValue = address.toString(); } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 5c26baef9..429c18cba 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1006,7 +1006,7 @@ void BitcoinGUI::dropEvent(QDropEvent *event) { if(event->mimeData()->hasUrls()) { - Q_FOREACH(const QUrl &uri, event->mimeData()->urls()) + for (const QUrl &uri : event->mimeData()->urls()) { Q_EMIT receivedURI(uri.toString()); } @@ -1202,7 +1202,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *pl QList units = BitcoinUnits::availableUnits(); int max_width = 0; const QFontMetrics fm(font()); - Q_FOREACH (const BitcoinUnits::Unit unit, units) + for (const BitcoinUnits::Unit unit : units) { max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit))); } @@ -1221,7 +1221,7 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event) void UnitDisplayStatusBarControl::createContextMenu() { menu = new QMenu(this); - Q_FOREACH(BitcoinUnits::Unit u, BitcoinUnits::availableUnits()) + for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) { QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this); menuAction->setData(QVariant(u)); diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 2229ee888..602926042 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -426,7 +426,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) CAmount nPayAmount = 0; bool fDust = false; CMutableTransaction txDummy; - Q_FOREACH(const CAmount &amount, CoinControlDialog::payAmounts) + for (const CAmount &amount : CoinControlDialog::payAmounts) { nPayAmount += amount; diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index efb25aaf1..fdf195398 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -84,7 +84,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : ui->lang->setToolTip(ui->lang->toolTip().arg(tr(PACKAGE_NAME))); ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant("")); - Q_FOREACH(const QString &langStr, translations.entryList()) + for (const QString &langStr : translations.entryList()) { QLocale locale(langStr); diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index c31a7a478..cb771e839 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -144,7 +144,7 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store) int nRootCerts = 0; const QDateTime currentTime = QDateTime::currentDateTime(); - Q_FOREACH (const QSslCertificate& cert, certList) { + for (const QSslCertificate& cert : certList) { // Don't log NULL certificates if (cert.isNull()) continue; @@ -267,7 +267,7 @@ void PaymentServer::ipcParseCommandLine(int argc, char* argv[]) bool PaymentServer::ipcSendCommandLine() { bool fResult = false; - Q_FOREACH (const QString& r, savedPaymentRequests) + for (const QString& r : savedPaymentRequests) { QLocalSocket* socket = new QLocalSocket(); socket->connectToServer(ipcServerName(), QIODevice::WriteOnly); @@ -392,7 +392,7 @@ void PaymentServer::uiReady() initNetManager(); saveURIs = false; - Q_FOREACH (const QString& s, savedPaymentRequests) + for (const QString& s : savedPaymentRequests) { handleURIOrFile(s); } @@ -555,7 +555,7 @@ bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, Sen QList > sendingTos = request.getPayTo(); QStringList addresses; - Q_FOREACH(const PAIRTYPE(CScript, CAmount)& sendingTo, sendingTos) { + for (const PAIRTYPE(CScript, CAmount)& sendingTo : sendingTos) { // Extract and check destination addresses CTxDestination dest; if (ExtractDestination(sendingTo.first, dest)) { @@ -742,7 +742,7 @@ void PaymentServer::reportSslErrors(QNetworkReply* reply, const QList Q_UNUSED(reply); QString errString; - Q_FOREACH (const QSslError& err, errs) { + for (const QSslError& err : errs) { qWarning() << "PaymentServer::reportSslErrors: " << err; errString += err.errorString() + "\n"; } diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 00dbcdce0..42934f805 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -62,7 +62,7 @@ public: #if QT_VERSION >= 0x040700 cachedNodeStats.reserve(vstats.size()); #endif - Q_FOREACH (const CNodeStats& nodestats, vstats) + for (const CNodeStats& nodestats : vstats) { CNodeCombinedStats stats; stats.nodeStateStats.nMisbehavior = 0; @@ -91,7 +91,7 @@ public: // build index map mapNodeRows.clear(); int row = 0; - Q_FOREACH (const CNodeCombinedStats& stats, cachedNodeStats) + for (const CNodeCombinedStats& stats : cachedNodeStats) mapNodeRows.insert(std::pair(stats.nodeStats.nodeid, row++)); } diff --git a/src/qt/platformstyle.cpp b/src/qt/platformstyle.cpp index 64a0d0058..1f4e1a442 100644 --- a/src/qt/platformstyle.cpp +++ b/src/qt/platformstyle.cpp @@ -48,7 +48,7 @@ void MakeSingleColorImage(QImage& img, const QColor& colorbase) QIcon ColorizeIcon(const QIcon& ico, const QColor& colorbase) { QIcon new_ico; - Q_FOREACH(const QSize sz, ico.availableSizes()) + for (const QSize sz : ico.availableSizes()) { QImage img(ico.pixmap(sz).toImage()); MakeSingleColorImage(img, colorbase); diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index e98f4d334..84f43266e 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -191,7 +191,7 @@ void ReceiveCoinsDialog::on_showRequestButton_clicked() return; QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows(); - Q_FOREACH (const QModelIndex& index, selection) { + for (const QModelIndex& index : selection) { on_recentRequestsView_doubleClicked(index); } } diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 272ab9486..cda33076f 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -265,7 +265,7 @@ void SendCoinsDialog::on_sendButton_clicked() // Format confirmation message QStringList formatted; - Q_FOREACH(const SendCoinsRecipient &rcp, currentTransaction.getRecipients()) + for (const SendCoinsRecipient &rcp : currentTransaction.getRecipients()) { // generate bold amount string QString amount = "" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount); @@ -319,7 +319,7 @@ void SendCoinsDialog::on_sendButton_clicked() questionString.append("
    "); CAmount totalAmount = currentTransaction.getTotalTransactionAmount() + txFee; QStringList alternativeUnits; - Q_FOREACH(BitcoinUnits::Unit u, BitcoinUnits::availableUnits()) + for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) { if(u != model->getOptionsModel()->getDisplayUnit()) alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u, totalAmount)); diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index f4377247e..10966e42e 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -188,7 +188,7 @@ void SplashScreen::unsubscribeFromCoreSignals() uiInterface.InitMessage.disconnect(boost::bind(InitMessage, this, _1)); uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2)); #ifdef ENABLE_WALLET - Q_FOREACH(CWallet* const & pwallet, connectedWallets) { + for (CWallet* const & pwallet : connectedWallets) { pwallet->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2)); } #endif diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp index 08a76c7d4..e812c5c38 100644 --- a/src/qt/test/paymentservertests.cpp +++ b/src/qt/test/paymentservertests.cpp @@ -196,7 +196,7 @@ void PaymentServerTests::paymentServerTests() QVERIFY(r.paymentRequest.IsInitialized()); // Extract address and amount from the request QList > sendingTos = r.paymentRequest.getPayTo(); - Q_FOREACH (const PAIRTYPE(CScript, CAmount)& sendingTo, sendingTos) { + for (const PAIRTYPE(CScript, CAmount)& sendingTo : sendingTos) { CTxDestination dest; if (ExtractDestination(sendingTo.first, dest)) QCOMPARE(PaymentServer::verifyAmount(sendingTo.second), false); diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp index 601d554c0..afd295c13 100644 --- a/src/qt/trafficgraphwidget.cpp +++ b/src/qt/trafficgraphwidget.cpp @@ -139,10 +139,10 @@ void TrafficGraphWidget::updateRates() } float tmax = 0.0f; - Q_FOREACH(float f, vSamplesIn) { + for (float f : vSamplesIn) { if(f > tmax) tmax = f; } - Q_FOREACH(float f, vSamplesOut) { + for (float f : vSamplesOut) { if(f > tmax) tmax = f; } fMax = tmax; diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 8e8873637..3b7a0a947 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -245,14 +245,14 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco strHTML += "" + tr("Output index") + ": " + QString::number(rec->getOutputIndex()) + "
    "; // Message from normal bitcoin:URI (bitcoin:123...?message=example) - Q_FOREACH (const PAIRTYPE(std::string, std::string)& r, wtx.vOrderForm) + for (const PAIRTYPE(std::string, std::string)& r : wtx.vOrderForm) if (r.first == "Message") strHTML += "
    " + tr("Message") + ":
    " + GUIUtil::HtmlEscape(r.second, true) + "
    "; // // PaymentRequest info: // - Q_FOREACH (const PAIRTYPE(std::string, std::string)& r, wtx.vOrderForm) + for (const PAIRTYPE(std::string, std::string)& r : wtx.vOrderForm) { if (r.first == "PaymentRequest") { diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index f27abc210..7ec84f170 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -145,7 +145,7 @@ public: { parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1); int insert_idx = lowerIndex; - Q_FOREACH(const TransactionRecord &rec, toInsert) + for (const TransactionRecord &rec : toInsert) { cachedWallet.insert(insert_idx, rec); insert_idx += 1; diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 7ab412528..c9b344fbd 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -106,7 +106,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : QTextCharFormat bold; bold.setFontWeight(QFont::Bold); - Q_FOREACH (const QString &line, coreOptions.split("\n")) { + for (const QString &line : coreOptions.split("\n")) { if (line.startsWith(" -")) { cursor.currentTable()->appendRows(1); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 84f0fd3da..449eb1ae5 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -207,7 +207,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact int nAddresses = 0; // Pre-check input data for validity - Q_FOREACH(const SendCoinsRecipient &rcp, recipients) + for (const SendCoinsRecipient &rcp : recipients) { if (rcp.fSubtractFeeFromAmount) fSubtractFeeFromAmount = true; @@ -310,7 +310,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran LOCK2(cs_main, wallet->cs_wallet); CWalletTx *newTx = transaction.getTransaction(); - Q_FOREACH(const SendCoinsRecipient &rcp, transaction.getRecipients()) + for (const SendCoinsRecipient &rcp : transaction.getRecipients()) { if (rcp.paymentRequest.IsInitialized()) { @@ -341,7 +341,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran // Add addresses / update labels that we've sent to to the address book, // and emit coinsSent signal for each recipient - Q_FOREACH(const SendCoinsRecipient &rcp, transaction.getRecipients()) + for (const SendCoinsRecipient &rcp : transaction.getRecipients()) { // Don't touch the address book when we have a payment request if (!rcp.paymentRequest.IsInitialized()) diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp index b4445c816..8bc9ef725 100644 --- a/src/qt/walletmodeltransaction.cpp +++ b/src/qt/walletmodeltransaction.cpp @@ -82,7 +82,7 @@ void WalletModelTransaction::reassignAmounts(int nChangePosRet) CAmount WalletModelTransaction::getTotalTransactionAmount() { CAmount totalTransactionAmount = 0; - Q_FOREACH(const SendCoinsRecipient &rcp, recipients) + for (const SendCoinsRecipient &rcp : recipients) { totalTransactionAmount += rcp.amount; } From 1238f13cf6ccf1177b66df735f360c61ae1dc20b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Fri, 2 Jun 2017 03:28:42 +0200 Subject: [PATCH 4/4] scripted-diff: Remove PAIRTYPE -BEGIN VERIFY SCRIPT- sed -i 's/PAIRTYPE(\([^,]*\), \([^\)]*\))/std::pair<\1, \2>/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; sed -i ':a;N;$!ba;s/#define std::pair std::pair\n//' ./src/utilstrencodings.h ; -END VERIFY SCRIPT- --- src/init.cpp | 2 +- src/qt/addresstablemodel.cpp | 2 +- src/qt/coincontroldialog.cpp | 2 +- src/qt/paymentserver.cpp | 2 +- src/qt/test/paymentservertests.cpp | 2 +- src/qt/transactiondesc.cpp | 4 ++-- src/rpc/blockchain.cpp | 2 +- src/rpc/net.cpp | 2 +- src/rpc/server.cpp | 2 +- src/script/standard.cpp | 2 +- src/sync.cpp | 10 +++++----- src/utilstrencodings.h | 1 - src/validation.cpp | 6 +++--- src/wallet/rpcwallet.cpp | 4 ++-- src/wallet/wallet.cpp | 14 +++++++------- 15 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 2c1f93727..5f50f70ac 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -611,7 +611,7 @@ void CleanupBlockRevFiles() // keeping a separate counter. Once we hit a gap (or if 0 doesn't exist) // start removing block files. int nContigCounter = 0; - for (const PAIRTYPE(std::string, fs::path)& item : mapBlockFiles) { + for (const std::pair& item : mapBlockFiles) { if (atoi(item.first) == nContigCounter) { nContigCounter++; continue; diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index 967933abf..d3ad24da0 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -81,7 +81,7 @@ public: cachedAddressTable.clear(); { LOCK(wallet->cs_wallet); - for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : wallet->mapAddressBook) + for (const std::pair& item : wallet->mapAddressBook) { const CBitcoinAddress& address = item.first; bool fMine = IsMine(*wallet, address.Get()); diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 602926042..6025a7409 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -628,7 +628,7 @@ void CoinControlDialog::updateView() std::map > mapCoins; model->listCoins(mapCoins); - for (const PAIRTYPE(QString, std::vector)& coins : mapCoins) { + for (const std::pair>& coins : mapCoins) { CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem(); itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); QString sWalletAddress = coins.first; diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index cb771e839..132ee3274 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -555,7 +555,7 @@ bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, Sen QList > sendingTos = request.getPayTo(); QStringList addresses; - for (const PAIRTYPE(CScript, CAmount)& sendingTo : sendingTos) { + for (const std::pair& sendingTo : sendingTos) { // Extract and check destination addresses CTxDestination dest; if (ExtractDestination(sendingTo.first, dest)) { diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp index e812c5c38..b9a8ad6e2 100644 --- a/src/qt/test/paymentservertests.cpp +++ b/src/qt/test/paymentservertests.cpp @@ -196,7 +196,7 @@ void PaymentServerTests::paymentServerTests() QVERIFY(r.paymentRequest.IsInitialized()); // Extract address and amount from the request QList > sendingTos = r.paymentRequest.getPayTo(); - for (const PAIRTYPE(CScript, CAmount)& sendingTo : sendingTos) { + for (const std::pair& sendingTo : sendingTos) { CTxDestination dest; if (ExtractDestination(sendingTo.first, dest)) QCOMPARE(PaymentServer::verifyAmount(sendingTo.second), false); diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 3b7a0a947..bcacc47ef 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -245,14 +245,14 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco strHTML += "" + tr("Output index") + ": " + QString::number(rec->getOutputIndex()) + "
    "; // Message from normal bitcoin:URI (bitcoin:123...?message=example) - for (const PAIRTYPE(std::string, std::string)& r : wtx.vOrderForm) + for (const std::pair& r : wtx.vOrderForm) if (r.first == "Message") strHTML += "
    " + tr("Message") + ":
    " + GUIUtil::HtmlEscape(r.second, true) + "
    "; // // PaymentRequest info: // - for (const PAIRTYPE(std::string, std::string)& r : wtx.vOrderForm) + for (const std::pair& r : wtx.vOrderForm) { if (r.first == "PaymentRequest") { diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 407fef14c..874311ec5 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1256,7 +1256,7 @@ UniValue getchaintips(const JSONRPCRequest& request) std::set setOrphans; std::set setPrevs; - for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { if (!chainActive.Contains(item.second)) { setOrphans.insert(item.second); diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 1364ff990..d6f9f0059 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -474,7 +474,7 @@ UniValue getnetworkinfo(const JSONRPCRequest& request) UniValue localAddresses(UniValue::VARR); { LOCK(cs_mapLocalHost); - for (const PAIRTYPE(CNetAddr, LocalServiceInfo) &item : mapLocalHost) + for (const std::pair &item : mapLocalHost) { UniValue rec(UniValue::VOBJ); rec.push_back(Pair("address", item.first.ToString())); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 48b2e4c27..a6d7d1a86 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -186,7 +186,7 @@ std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest& jreq.fHelp = true; jreq.params = UniValue(); - for (const PAIRTYPE(std::string, const CRPCCommand*)& command : vCommands) + for (const std::pair& command : vCommands) { const CRPCCommand *pcmd = command.second; std::string strMethod = pcmd->name; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 85b33778b..7efcad7b0 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -94,7 +94,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector& tplate : mTemplates) { const CScript& script2 = tplate.second; vSolutionsRet.clear(); diff --git a/src/sync.cpp b/src/sync.cpp index d32202b70..94f2cafa9 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -77,7 +77,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, { LogPrintf("POTENTIAL DEADLOCK DETECTED\n"); LogPrintf("Previous lock order was:\n"); - for (const PAIRTYPE(void*, CLockLocation) & i : s2) { + for (const std::pair & i : s2) { if (i.first == mismatch.first) { LogPrintf(" (1)"); } @@ -87,7 +87,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, LogPrintf(" %s\n", i.second.ToString()); } LogPrintf("Current lock order is:\n"); - for (const PAIRTYPE(void*, CLockLocation) & i : s1) { + for (const std::pair & i : s1) { if (i.first == mismatch.first) { LogPrintf(" (1)"); } @@ -108,7 +108,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry) (*lockstack).push_back(std::make_pair(c, locklocation)); - for (const PAIRTYPE(void*, CLockLocation) & i : (*lockstack)) { + for (const std::pair & i : (*lockstack)) { if (i.first == c) break; @@ -142,14 +142,14 @@ void LeaveCritical() std::string LocksHeld() { std::string result; - for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) + for (const std::pair & i : *lockstack) result += i.second.ToString() + std::string("\n"); return result; } void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) { - for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack) + for (const std::pair & i : *lockstack) if (i.first == cs) return; fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str()); diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index 8846cb47e..8b37fe12e 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -18,7 +18,6 @@ #define UBEGIN(a) ((unsigned char*)&(a)) #define UEND(a) ((unsigned char*)&((&(a))[1])) #define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0])) -#define PAIRTYPE(t1, t2) std::pair /** Used by SanitizeString() */ enum SafeChars diff --git a/src/validation.cpp b/src/validation.cpp index ddedbdb97..d07c1437e 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3300,13 +3300,13 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) // Calculate nChainWork std::vector > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); - for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { CBlockIndex* pindex = item.second; vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex)); } sort(vSortedByHeight.begin(), vSortedByHeight.end()); - for (const PAIRTYPE(int, CBlockIndex*)& item : vSortedByHeight) + for (const std::pair& item : vSortedByHeight) { CBlockIndex* pindex = item.second; pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex); @@ -3355,7 +3355,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) // Check presence of blk files LogPrintf("Checking all blk files are present...\n"); std::set setBlkDataFiles; - for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex) + for (const std::pair& item : mapBlockIndex) { CBlockIndex* pindex = item.second; if (pindex->nStatus & BLOCK_HAVE_DATA) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index cfc9ee5c1..f03137216 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -96,7 +96,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) } entry.push_back(Pair("bip125-replaceable", rbfStatus)); - for (const PAIRTYPE(std::string, std::string)& item : wtx.mapValue) + for (const std::pair& item : wtx.mapValue) entry.push_back(Pair(item.first, item.second)); } @@ -1673,7 +1673,7 @@ UniValue listaccounts(const JSONRPCRequest& request) mapAccountBalances[entry.strAccount] += entry.nCreditDebit; UniValue ret(UniValue::VOBJ); - for (const PAIRTYPE(std::string, CAmount)& accountBalance : mapAccountBalances) { + for (const std::pair& accountBalance : mapAccountBalances) { ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); } return ret; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 531a1fabf..e6e14c6c7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -804,7 +804,7 @@ void CWallet::MarkDirty() { { LOCK(cs_wallet); - for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) + for (std::pair& item : mapWallet) item.second.MarkDirty(); } } @@ -1525,7 +1525,7 @@ void CWallet::ReacceptWalletTransactions() std::map mapSorted; // Sort pending wallet transactions based on their initial wallet insertion order - for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) + for (std::pair& item : mapWallet) { const uint256& wtxid = item.first; CWalletTx& wtx = item.second; @@ -1539,7 +1539,7 @@ void CWallet::ReacceptWalletTransactions() } // Try to add wallet transactions to memory pool - for (PAIRTYPE(const int64_t, CWalletTx*)& item : mapSorted) + for (std::pair& item : mapSorted) { CWalletTx& wtx = *(item.second); @@ -1796,7 +1796,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon LOCK(cs_wallet); // Sort them in chronological order std::multimap mapSorted; - for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) + for (std::pair& item : mapWallet) { CWalletTx& wtx = item.second; // Don't rebroadcast if newer than nTime: @@ -1804,7 +1804,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon continue; mapSorted.insert(std::make_pair(wtx.nTimeReceived, &wtx)); } - for (PAIRTYPE(const unsigned int, CWalletTx*)& item : mapSorted) + for (std::pair& item : mapSorted) { CWalletTx& wtx = *item.second; if (wtx.RelayWalletTransaction(connman)) @@ -3010,7 +3010,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address) // Delete destdata tuples associated with address std::string strAddress = CBitcoinAddress(address).ToString(); - for (const PAIRTYPE(std::string, std::string) &item : mapAddressBook[address].destdata) + for (const std::pair &item : mapAddressBook[address].destdata) { CWalletDB(*dbw).EraseDestData(strAddress, item.first); } @@ -3388,7 +3388,7 @@ std::set CWallet::GetAccountAddresses(const std::string& strAcco { LOCK(cs_wallet); std::set result; - for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : mapAddressBook) + for (const std::pair& item : mapAddressBook) { const CTxDestination& address = item.first; const std::string& strName = item.second.name;