diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index ec6e7a2c1..0e86568e5 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/bloom.cpp b/src/bloom.cpp index 3f7a49c9f..1a58b8714 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -272,7 +272,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 08017ff79..d7b7b836d 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -120,7 +120,7 @@ private: fOk = fAllOk; } // execute work - BOOST_FOREACH (T& check, vChecks) + for (T& check : vChecks) if (fOk) fOk = check(); vChecks.clear(); @@ -150,7 +150,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 702f9b413..edb60b55d 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -146,7 +146,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); } @@ -160,7 +160,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, entry.pushKV("locktime", (int64_t)tx.nLockTime); UniValue vin(UniValue::VARR); - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { UniValue in(UniValue::VOBJ); if (tx.IsCoinBase()) in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); diff --git a/src/dash-tx.cpp b/src/dash-tx.cpp index ee2975416..420a39a4a 100644 --- a/src/dash-tx.cpp +++ b/src/dash-tx.cpp @@ -585,7 +585,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr) SignSignature(keystore, prevPubKey, mergedTx, i, nHashType); // ... and merge in other signatures: - BOOST_FOREACH(const CTransaction& txv, txVariants) { + for (const CTransaction& txv : txVariants) { txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig); } if (!VerifyScript(txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&mergedTx, i))) diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 28a6d9867..e0b943045 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -94,7 +94,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 242be4063..f30e91b7e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -746,7 +746,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; @@ -799,7 +799,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()); @@ -1587,7 +1587,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) } 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)); @@ -1602,7 +1602,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)); @@ -1616,7 +1616,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()) @@ -1678,7 +1678,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)); @@ -1686,7 +1686,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)); @@ -1706,7 +1706,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); @@ -2094,7 +2094,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 79218bc62..261052d77 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -275,7 +275,7 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, unsigned int packageSigOp // - safe TXs in regard to ChainLocks bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package) { - BOOST_FOREACH (const CTxMemPool::txiter it, package) { + for (const CTxMemPool::txiter it : package) { if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff)) return false; if (!llmq::chainLocksHandler->IsTxSafeForMining(it->GetTx().GetHash())) { @@ -308,11 +308,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 8a8e94a17..ee12a2686 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -305,7 +305,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; @@ -314,7 +314,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; @@ -323,7 +323,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); } @@ -334,7 +334,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; @@ -343,7 +343,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; } @@ -537,7 +537,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; } @@ -615,7 +615,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; } @@ -986,7 +986,7 @@ bool CConnman::AttemptToEvictConnection() { LOCK(cs_vNodes); - BOOST_FOREACH(CNode *node, vNodes) { + for (CNode *node : vNodes) { if (node->fWhitelisted) continue; if (!node->fInbound) @@ -1066,7 +1066,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(); @@ -1111,7 +1111,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++; if (!pnode->verifiedProRegTxHash.IsNull()) { @@ -1206,7 +1206,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) { @@ -1232,7 +1232,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) { @@ -1292,7 +1292,7 @@ void CConnman::ThreadSocketHandler() have_fds = true; #endif - 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; @@ -1300,7 +1300,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 @@ -1377,7 +1377,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)) { @@ -1389,7 +1389,7 @@ void CConnman::ThreadSocketHandler() // Service each socket // std::vector vNodesCopy = CopyNodeVector(); - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) { if (interruptNet) return; @@ -1703,7 +1703,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; } @@ -1715,7 +1715,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); @@ -1796,7 +1796,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()); @@ -1852,7 +1852,7 @@ void CConnman::ThreadOpenConnections() std::set > setConnected; if (!Params().AllowMultipleAddressesFromGroup()) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) { + for (CNode* pnode : vNodes) { if (!pnode->fInbound && !pnode->fAddnode && !pnode->fMasternode) { // Count the peers that have all relevant services @@ -1978,7 +1978,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); } @@ -1999,7 +1999,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 @@ -2203,7 +2203,7 @@ void CConnman::ThreadMessageHandler() bool fMoreWork = false; - BOOST_FOREACH(CNode* pnode, vNodesCopy) + for (CNode* pnode : vNodesCopy) { if (pnode->fDisconnect) continue; @@ -2349,7 +2349,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()); @@ -2396,7 +2396,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 { @@ -2642,18 +2642,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(); @@ -2894,7 +2894,7 @@ void CConnman::RelayTransaction(const CTransaction& tx) } CInv inv(nInv, hash); LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) { pnode->PushInventory(inv); } @@ -3135,7 +3135,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 da1c2232c..2488178ac 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -323,7 +323,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); @@ -558,7 +558,7 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vectorIsValid(BLOCK_VALID_TREE)) { // We consider the chain that this peer is on invalid. return; @@ -598,7 +598,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); } @@ -659,7 +659,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); } @@ -675,7 +675,7 @@ int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) 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()) @@ -826,7 +826,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); @@ -1147,7 +1147,7 @@ void static ProcessGetBlockData(CNode* pfrom, const Consensus::Params& consensus // 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(NetMsgType::TX, *pblock->vtx[pair.first])); } // else @@ -1708,7 +1708,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; @@ -2216,20 +2216,20 @@ 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; } } if (!fRejectedParents) { - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { CInv _inv(MSG_TX, txin.prevout.hash); pfrom->AddInventoryKnown(_inv); if (!AlreadyHave(_inv)) pfrom->AskFor(_inv); @@ -2748,7 +2748,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); } @@ -2944,7 +2944,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr else { bool found = false; const std::vector &allMessages = getAllNetMessageTypes(); - BOOST_FOREACH(const std::string msg, allMessages) { + for (const std::string msg : allMessages) { if(msg == strCommand) { found = true; break; @@ -2984,7 +2984,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(); @@ -3205,7 +3205,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())) { @@ -3284,7 +3284,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; @@ -3412,7 +3412,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& interr vInv.reserve(std::max(pto->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX_PER_1MB_BLOCK * MaxBlockSize(true) / 1000000)); // 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)); @@ -3606,7 +3606,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) { vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash())); MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex); LogPrint(BCLog::NET, "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(), diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index 1b1b30017..cf07968e1 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -92,7 +92,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason) 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 @@ -113,7 +113,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason) unsigned int nDataOut = 0; txnouttype whichType; - BOOST_FOREACH(const CTxOut& txout, tx.vout) { + for (const CTxOut& txout : tx.vout) { if (!::IsStandard(txout.scriptPubKey, whichType)) { reason = "scriptpubkey"; return false; diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index 61a024ded..7f452faee 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -82,7 +82,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 f6c47e025..e96c313c9 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -504,7 +504,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(); @@ -672,7 +672,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; @@ -699,7 +699,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 33b1f611f..6f4eb86a3 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 fd57b494a..e18509835 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 8a495eddc..3a1f395dd 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -149,7 +149,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()) @@ -168,14 +168,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; @@ -189,7 +189,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); @@ -237,10 +237,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)) + "
"; } @@ -292,10 +292,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)) + "
"; @@ -305,7 +305,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 fb78a17f9..7fde2aa43 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -83,7 +83,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet * int nFromMe = 0; bool involvesWatchAddress = false; isminetype fAllFromMe = ISMINE_SPENDABLE; - BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) + for (const CTxIn& txin : wtx.tx->vin) { if(wallet->IsMine(txin)) { fAllFromMeDenom = fAllFromMeDenom && wallet->IsDenominated(txin.prevout); @@ -97,7 +97,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet * isminetype fAllToMe = ISMINE_SPENDABLE; bool fAllToMeDenom = true; int nToMe = 0; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) { + for (const CTxOut& txout : wtx.tx->vout) { if(wallet->IsMine(txout)) { fAllToMeDenom = fAllToMeDenom && CPrivateSend::IsDenominatedAmount(txout.nValue); nToMe++; diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 71b3b37b2..b62120245 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -79,7 +79,7 @@ CAmount WalletModel::getBalance(const CCoinControl *coinControl) const CAmount nBalance = 0; std::vector vCoins; wallet->AvailableCoins(vCoins, true, coinControl); - BOOST_FOREACH(const COutput& out, vCoins) + for (const COutput& out : vCoins) if(out.fSpendable) nBalance += out.tx->tx->vout[out.i].nValue; @@ -681,7 +681,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(); @@ -708,7 +708,7 @@ void WalletModel::listCoins(std::map >& mapCoins) wallet->ListLockedCoins(vLockedCoins); // add locked coins - BOOST_FOREACH(const COutPoint& outpoint, vLockedCoins) + for (const COutPoint& outpoint : vLockedCoins) { if (!wallet->mapWallet.count(outpoint.hash)) continue; int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); @@ -718,7 +718,7 @@ void WalletModel::listCoins(std::map >& mapCoins) vCoins.push_back(out); } - BOOST_FOREACH(const COutput& out, vCoins) + for (const COutput& out : vCoins) { COutput cout = out; @@ -768,8 +768,8 @@ void WalletModel::listProTxCoins(std::vector& vOutpts) void WalletModel::loadReceiveRequests(std::vector& vReceiveRequests) { LOCK(wallet->cs_wallet); - BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook) - BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item2, item.second.destdata) + for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : wallet->mapAddressBook) + for (const PAIRTYPE(std::string, std::string)& item2 : item.second.destdata) if (item2.first.size() > 2 && item2.first.substr(0,2) == "rr") // receive request vReceiveRequests.push_back(item2.second); } diff --git a/src/rest.cpp b/src/rest.cpp index 7bca7488e..692205792 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 7806f425a..a5350626e 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -387,14 +387,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); } @@ -409,7 +409,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); @@ -424,7 +424,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; @@ -509,14 +509,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); @@ -573,14 +573,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); @@ -1512,7 +1512,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); @@ -1541,7 +1541,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) { const CBlockIndex* pindexFork = chainActive.FindFork(block); const int branchLen = block->nHeight - pindexFork->nHeight; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 00ae7a059..f4ef6cebd 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -601,7 +601,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request) entry.push_back(Pair("hash", txHash.GetHex())); UniValue deps(UniValue::VARR); - BOOST_FOREACH (const CTxIn &in, tx.vin) + for (const CTxIn &in : tx.vin) { if (setTxIndex.count(in.prevout.hash)) deps.push_back(setTxIndex[in.prevout.hash]); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 41fda5f9b..ef886dbc1 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -232,7 +232,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 3d31b52d5..4f94b2cfd 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -127,7 +127,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); @@ -164,7 +164,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)); @@ -172,14 +172,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)); } @@ -475,7 +475,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 e5b7d64a0..676a9521b 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -332,7 +332,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; } @@ -423,7 +423,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"); @@ -682,7 +682,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. } @@ -821,7 +821,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) SignSignature(keystore, prevPubKey, mergedTx, i, nHashType); // ... and merge in other signatures: - BOOST_FOREACH(const CMutableTransaction& txv, txVariants) { + for (const CMutableTransaction& txv : txVariants) { if (txv.vin.size() > i) { txin.scriptSig = CombineSignatures(prevPubKey, txConst, i, txin.scriptSig, txv.vin[i].scriptSig); } diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 8eb15d315..5a41a12d8 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) { @@ -233,7 +233,7 @@ std::string CRPCTable::help(const std::string& strCommand, const std::string& st 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 a66e79bef..fe9215c67 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 c945972a4..9e4424e7c 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -148,7 +148,7 @@ bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CMutab static CScript PushAll(const std::vector& values) { CScript result; - BOOST_FOREACH(const valtype& v, values) + for (const valtype& v : values) result << v; return result; } @@ -159,12 +159,12 @@ static CScript CombineMultisig(const CScript& scriptPubKey, const BaseSignatureC { // 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); @@ -175,7 +175,7 @@ static CScript CombineMultisig(const CScript& scriptPubKey, const BaseSignatureC 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 616b30cca..128513f65 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -76,7 +76,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 924223630..092b8df17 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -77,7 +77,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, std::string strOutput = ""; strOutput += "POTENTIAL DEADLOCK DETECTED\n"; strOutput += "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) { strOutput += " (1)"; } @@ -87,7 +87,7 @@ static void potential_deadlock_detected(const std::pair& mismatch, strOutput += strprintf(" %s\n", i.second.ToString().c_str()); } strOutput += "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) { strOutput += " (1)"; } @@ -112,7 +112,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; @@ -146,14 +146,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 402aef27a..ab040c5cc 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 f6e8adab8..58f77731b 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -201,7 +201,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 b9ce280d0..28bec6374 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()); gArgs.ParseParameters(vecChar.size(), &vecChar[0]); diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index 2c2f76323..d1dc6ed80 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 2c36f1238..01308cbbb 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -53,13 +53,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 13a996499..623dbf0ef 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -676,7 +676,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 @@ -769,7 +769,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_dash.cpp b/src/test/test_dash.cpp index a99b6ac49..12fab1446 100644 --- a/src/test/test_dash.cpp +++ b/src/test/test_dash.cpp @@ -159,7 +159,7 @@ CBlock TestChainSetup::CreateBlock(const std::vector& txns, block.vtx.resize(1); // Re-add quorum commitments block.vtx.insert(block.vtx.end(), llmqCommitments.begin(), llmqCommitments.end()); - BOOST_FOREACH(const CMutableTransaction& tx, txns) + for (const CMutableTransaction& tx : txns) block.vtx.push_back(MakeTransactionRef(tx)); // Manually update CbTx as we modified the block here diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 968111182..dddeacf2d 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -55,7 +55,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 << "'"); diff --git a/src/timedata.cpp b/src/timedata.cpp index e5cdd5497..6549ecd53 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 e2ba2209b..944b4e6f4 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -486,7 +486,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()) @@ -616,7 +616,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); @@ -633,7 +633,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 2542091c5..e5c8c5664 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -74,12 +74,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)) { @@ -93,7 +93,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(); @@ -203,7 +203,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); @@ -222,13 +222,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)); } } @@ -239,7 +239,7 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto int64_t updateSize = 0; CAmount updateFee = 0; int updateSigOps = 0; - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { updateSize += ancestorIt->GetTxSize(); updateFee += ancestorIt->GetModifiedFee(); updateSigOps += ancestorIt->GetSigOpCount(); @@ -250,7 +250,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); } } @@ -267,19 +267,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->GetSigOpCount(); - 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; @@ -308,7 +308,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); } } @@ -402,7 +402,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); @@ -628,7 +628,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) { @@ -717,7 +717,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); } @@ -749,7 +749,7 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReaso } } setEntries setAllRemoves; - BOOST_FOREACH(txiter it, txToRemove) { + for (txiter it : txToRemove) { CalculateDescendants(it, setAllRemoves); } @@ -771,7 +771,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; @@ -798,7 +798,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; @@ -1035,7 +1035,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const setEntries setParentCheck; int64_t parentSizes = 0; unsigned int parentSigOpCount = 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()) { @@ -1067,7 +1067,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const CAmount nFeesCheck = it->GetModifiedFee(); unsigned int nSigOpCheck = it->GetSigOpCount(); - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { nSizeCheck += ancestorIt->GetTxSize(); nFeesCheck += ancestorIt->GetModifiedFee(); nSigOpCheck += ancestorIt->GetSigOpCount(); @@ -1329,14 +1329,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; @@ -1396,7 +1396,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); } } @@ -1415,7 +1415,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); @@ -1524,13 +1524,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; pvNoSpendsRemaining->push_back(txin.prevout); } diff --git a/src/validation.cpp b/src/validation.cpp index 969d24211..2509da14d 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -177,7 +177,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()) { @@ -411,7 +411,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); @@ -579,7 +579,7 @@ static 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); } @@ -709,7 +709,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool // Check for conflicts with in-memory transactions { 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()) @@ -746,7 +746,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool } // 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); } @@ -791,7 +791,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool // 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; @@ -913,7 +913,7 @@ static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPo bool res = AcceptToMemoryPoolWorker(chainparams, pool, state, tx, fLimitFree, pfMissingInputs, nAcceptTime, fOverrideMempoolLimit, nAbsurdFee, coins_to_uncache, fDryRun); if (!res || fDryRun) { if(!res) LogPrint(BCLog::MEMPOOL, "%s: %s %s (%s)\n", __func__, tx->GetHash().ToString(), state.GetRejectReason(), state.GetDebugMessage()); - 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 @@ -1355,7 +1355,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(); bool is_spent = inputs.SpendCoin(txin.prevout, &txundo.vprevout.back()); assert(is_spent); @@ -3710,7 +3710,7 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, static 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; @@ -3929,7 +3929,7 @@ 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)); @@ -3940,7 +3940,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) } } 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); @@ -3989,7 +3989,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) { @@ -4176,7 +4176,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 3e50059e6..1f54d7430 100644 --- a/src/wallet/crypter.cpp +++ b/src/wallet/crypter.cpp @@ -348,7 +348,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 67f9f223f..24f805562 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -204,7 +204,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 8b5ccb97c..05af581dc 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 { @@ -1311,7 +1311,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 39a8267c8..0e668d726 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -86,13 +86,13 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) uint256 hash = wtx.GetHash(); entry.push_back(Pair("txid", hash.GetHex())); UniValue conflicts(UniValue::VARR); - BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts()) + for (const uint256& conflict : wtx.GetConflicts()) conflicts.push_back(conflict.GetHex()); entry.push_back(Pair("walletconflicts", conflicts)); entry.push_back(Pair("time", wtx.GetTxTime())); entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived)); - BOOST_FOREACH(const PAIRTYPE(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)); } @@ -503,7 +503,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()); @@ -673,7 +673,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) || (fAddLocked && wtx.IsLockedByInstantSend())) nAmount += txout.nValue; @@ -730,7 +730,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)) { @@ -1004,7 +1004,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()) @@ -1158,7 +1158,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA if ((nDepth < nMinDepth) && !(fAddLocked && wtx.IsLockedByInstantSend())) continue; - BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) + for (const CTxOut& txout : wtx.tx->vout) { CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address)) @@ -1222,7 +1222,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()); } @@ -1360,7 +1360,7 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const std:: // 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)) { @@ -1386,7 +1386,7 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const std:: // Received if (listReceived.size() > 0 && ((wtx.GetDepthInMainChain() >= nMinDepth) || wtx.IsLockedByInstantSend())) { - BOOST_FOREACH(const COutputEntry& r, listReceived) + for (const COutputEntry& r : listReceived) { std::string account; if (pwallet->mapAddressBook.count(r.destination)) { @@ -1634,11 +1634,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) || (fAddLocked && wtx.IsLockedByInstantSend())) { - 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; } @@ -1648,11 +1648,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; @@ -2327,7 +2327,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())); @@ -2583,7 +2583,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()); } @@ -2709,7 +2709,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 eb14d176b..927aa980c 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 976d55f7b..065dadf7a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -436,7 +436,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool fForMixingOnl { LOCK(cs_wallet); - BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys) + for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys) { if (!crypter.SetKeyFromPassphrase(strWalletPassphraseFinal, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; @@ -481,7 +481,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, CCrypter crypter; CKeyingMaterial _vMasterKey; - BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys) + for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys) { if(!crypter.SetKeyFromPassphrase(strOldWalletPassphraseFinal, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; @@ -585,7 +585,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 @@ -711,7 +711,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); } @@ -858,7 +858,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))); } @@ -888,7 +888,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; @@ -977,7 +977,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; @@ -1003,7 +1003,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(); } @@ -1108,7 +1108,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()) { @@ -1140,7 +1140,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()) { @@ -1214,7 +1214,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(); @@ -1278,7 +1278,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(); @@ -1299,7 +1299,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(); @@ -1649,7 +1649,7 @@ bool CWallet::IsHDEnabled() 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; @@ -1663,7 +1663,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)) @@ -1676,7 +1676,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()) @@ -1696,7 +1696,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)) @@ -1708,7 +1708,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)) @@ -1885,7 +1885,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; @@ -1899,7 +1899,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); @@ -2206,7 +2206,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); @@ -2235,7 +2235,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: @@ -2243,7 +2243,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)) @@ -2729,7 +2729,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin LogPrint(BCLog::SELECTCOINS, "tryDenom: %d\n", tryDenom); vValue.clear(); nTotalLower = 0; - BOOST_FOREACH(const COutput &output, vCoins) + for (const COutput &output : vCoins) { if (!output.fSpendable) continue; @@ -2851,7 +2851,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; @@ -2881,7 +2881,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()) @@ -2951,7 +2951,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); int nExtraPayloadSize = 0; @@ -2971,7 +2971,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)) { @@ -3614,7 +3614,7 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, CWalletT // If there was change output added before, we must update its position now if (nChangePosInOut != -1) { int i = 0; - BOOST_FOREACH(const CTxOut& txOut, txNew.vout) + for (const CTxOut& txOut : txNew.vout) { if (txOut == newTxOut) { @@ -3773,7 +3773,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon // Notify that old coins are spent std::set updated_hahes; - BOOST_FOREACH(const CTxIn& txin, wtxNew.tx->vin) + for (const CTxIn& txin : wtxNew.tx->vin) { // notify only once if(updated_hahes.find(txin.prevout.hash) != updated_hahes.end()) continue; @@ -3987,7 +3987,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); } @@ -4032,11 +4032,11 @@ bool CWallet::NewKeyPool() { LOCK(cs_wallet); CWalletDB walletdb(*dbw); - BOOST_FOREACH(int64_t nIndex, setInternalKeyPool) { + for (int64_t nIndex : setInternalKeyPool) { walletdb.ErasePool(nIndex); } setInternalKeyPool.clear(); - BOOST_FOREACH(int64_t nIndex, setExternalKeyPool) { + for (int64_t nIndex : setExternalKeyPool) { walletdb.ErasePool(nIndex); } setExternalKeyPool.clear(); @@ -4291,7 +4291,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 */ @@ -4305,7 +4305,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; @@ -4336,18 +4336,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); @@ -4356,12 +4356,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; @@ -4374,7 +4374,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; @@ -4423,7 +4423,7 @@ void CReserveKey::ReturnKey() static void LoadReserveKeysToSet(std::set& setAddress, const std::set& setKeyPool, CWalletDB& walletdb) { - BOOST_FOREACH(const int64_t& id, setKeyPool) + for (const int64_t& id : setKeyPool) { CKeyPool keypool; if (!walletdb.ReadPool(id, keypool)) @@ -4444,7 +4444,7 @@ void CWallet::GetAllReserveKeys(std::set& setAddress) const LoadReserveKeysToSet(setAddress, setInternalKeyPool, walletdb); LoadReserveKeysToSet(setAddress, setExternalKeyPool, walletdb); - BOOST_FOREACH (const CKeyID& keyID, setAddress) { + for (const CKeyID& keyID : setAddress) { if (!HaveKey(keyID)) { throw std::runtime_error(std::string(__func__) + ": unknown key in key pool"); } @@ -4538,7 +4538,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); } } @@ -4573,7 +4573,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; } @@ -4592,10 +4592,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) @@ -4934,7 +4934,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 ec6871036..a2d0a2fc0 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; @@ -668,7 +668,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: @@ -683,7 +683,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))); } @@ -769,7 +769,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++; } @@ -800,7 +800,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; }