scripted-diff: Fully remove BOOST_FOREACH

-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
This commit is contained in:
Jorge Timón 2017-06-02 03:18:57 +02:00 committed by Jack Grigg
parent 32433c2baf
commit 92a867febc
49 changed files with 307 additions and 307 deletions

View File

@ -47,10 +47,10 @@ void CUnsignedAlert::SetNull()
std::string CUnsignedAlert::ToString() const
{
std::string strSetCancel;
BOOST_FOREACH(int n, setCancel)
for (int n : setCancel)
strSetCancel += strprintf("%d ", n);
std::string strSetSubVer;
BOOST_FOREACH(const std::string& str, setSubVer)
for (const std::string& str : setSubVer)
strSetSubVer += "\"" + str + "\" ";
return strprintf(
"CAlert(\n"
@ -240,7 +240,7 @@ bool CAlert::ProcessAlert(const std::vector<unsigned char>& alertKey, bool fThre
}
// Check if this alert has been cancelled
BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts)
{
const CAlert& alert = item.second;
if (alert.Cancels(*this))

View File

@ -489,7 +489,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& strInput)
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata, consensusBranchId);
// ... and merge in other signatures:
BOOST_FOREACH(const CTransaction& txv, txVariants)
for (const CTransaction& txv : txVariants)
sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i), consensusBranchId);
UpdateTransaction(mergedTx, i, sigdata);

View File

@ -181,7 +181,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))

View File

@ -119,7 +119,7 @@ private:
fOk = fAllOk;
}
// execute work
BOOST_FOREACH (T& check, vChecks)
for (T& check : vChecks)
if (fOk)
fOk = check();
vChecks.clear();
@ -146,7 +146,7 @@ public:
void Add(std::vector<T>& vChecks)
{
boost::unique_lock<boost::mutex> lock(mutex);
BOOST_FOREACH (T& check, vChecks) {
for (T& check : vChecks) {
queue.push_back(T());
check.swap(queue.back());
}

View File

@ -920,9 +920,9 @@ std::optional<UnsatisfiedShieldedReq> CCoinsViewCache::HaveShieldedRequirements(
{
boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;
BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit)
for (const JSDescription &joinsplit : tx.vJoinSplit)
{
BOOST_FOREACH(const uint256& nullifier, joinsplit.nullifiers)
for (const uint256& nullifier : joinsplit.nullifiers)
{
if (GetNullifier(nullifier, SPROUT)) {
// If the nullifier is set, this transaction
@ -949,7 +949,7 @@ std::optional<UnsatisfiedShieldedReq> CCoinsViewCache::HaveShieldedRequirements(
return UnsatisfiedShieldedReq::SproutUnknownAnchor;
}
BOOST_FOREACH(const uint256& commitment, joinsplit.commitments)
for (const uint256& commitment : joinsplit.commitments)
{
tree.append(commitment);
}
@ -1011,7 +1011,7 @@ double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const
// FIXME: this logic is partially duplicated between here and CreateNewBlock in miner.cpp.
double dResult = 0.0;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
{
const CCoins* coins = AccessCoins(txin.prevout.hash);
assert(coins);

View File

@ -120,7 +120,7 @@ public:
}
void ClearUnspendable() {
BOOST_FOREACH(CTxOut &txout, vout) {
for (CTxOut &txout : vout) {
if (txout.scriptPubKey.IsUnspendable())
txout.SetNull();
}
@ -228,7 +228,7 @@ public:
//! check whether the entire CCoins is spent
//! note that only !IsPruned() CCoins can be serialized
bool IsPruned() const {
BOOST_FOREACH(const CTxOut &out, vout)
for (const CTxOut &out : vout)
if (!out.IsNull())
return false;
return true;
@ -236,7 +236,7 @@ public:
size_t DynamicMemoryUsage() const {
size_t ret = memusage::DynamicUsage(vout);
BOOST_FOREACH(const CTxOut &out, vout) {
for (const CTxOut &out : vout) {
ret += RecursiveDynamicUsage(out.scriptPubKey);
}
return ret;

View File

@ -157,7 +157,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()));

View File

@ -281,7 +281,7 @@ for test_input in TEST_VECTORS:
}
};
BOOST_FOREACH(std::vector<std::string>& v, tests) {
for (std::vector<std::string>& v : tests) {
Ed25519VerificationKey joinSplitPubKey;
auto pubKeyBytes = uint256S(v[3]);
std::copy(pubKeyBytes.begin(), pubKeyBytes.end(), joinSplitPubKey.bytes);

View File

@ -95,7 +95,7 @@ void test_tree(
expect_ser_test_vector(ser_tests[i], tree, tree);
bool first = true; // The first witness can never form a path
BOOST_FOREACH(Witness& wit, witnesses)
for (Witness& wit : witnesses)
{
// Append the same commitment to all the witnesses
wit.append(test_commitment);
@ -121,7 +121,7 @@ void test_tree(
// Tree should be full now
ASSERT_THROW(tree.append(uint256()), std::runtime_error);
BOOST_FOREACH(Witness& wit, witnesses)
for (Witness& wit : witnesses)
{
ASSERT_THROW(wit.append(uint256()), std::runtime_error);
}

View File

@ -90,7 +90,7 @@ static bool multiUserAuthorized(std::string strUserPass)
if (mapMultiArgs.count("-rpcauth") > 0) {
//Search for multi-user login/pass "rpcauth" from config
BOOST_FOREACH(std::string strRPCAuth, mapMultiArgs["-rpcauth"])
for (std::string strRPCAuth : mapMultiArgs["-rpcauth"])
{
std::vector<std::string> vFields;
boost::split(vFields, strRPCAuth, boost::is_any_of(":$"));

View File

@ -574,7 +574,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(string, path)& item, mapBlockFiles) {
for (const PAIRTYPE(string, path)& item : mapBlockFiles) {
if (atoi(item.first) == nContigCounter) {
nContigCounter++;
continue;
@ -640,7 +640,7 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
}
// -loadblock=
BOOST_FOREACH(const fs::path& path, vImportFiles) {
for (const fs::path& path : vImportFiles) {
FILE *file = fsbridge::fopen(path, "rb");
if (file) {
CImportingNow imp;
@ -1240,7 +1240,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// sanitize comments per BIP-0014, format user agent and check total size
std::vector<string> uacomments;
BOOST_FOREACH(string cmt, mapMultiArgs["-uacomment"])
for (string cmt : mapMultiArgs["-uacomment"])
{
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
return InitError(strprintf("User Agent comment (%s) contains unsafe characters.", cmt));
@ -1254,7 +1254,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (mapArgs.count("-onlynet")) {
std::set<enum Network> nets;
BOOST_FOREACH(const std::string& snet, mapMultiArgs["-onlynet"]) {
for (const std::string& snet : mapMultiArgs["-onlynet"]) {
enum Network net = ParseNetwork(snet);
if (net == NET_UNROUTABLE)
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
@ -1268,7 +1268,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}
if (mapArgs.count("-whitelist")) {
BOOST_FOREACH(const std::string& net, mapMultiArgs["-whitelist"]) {
for (const std::string& net : mapMultiArgs["-whitelist"]) {
CSubNet subnet(net);
if (!subnet.IsValid())
return InitError(strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net));
@ -1317,13 +1317,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
bool fBound = false;
if (fListen) {
if (mapArgs.count("-bind") || mapArgs.count("-whitebind")) {
BOOST_FOREACH(const std::string& strBind, mapMultiArgs["-bind"]) {
for (const std::string& strBind : mapMultiArgs["-bind"]) {
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind));
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR));
}
BOOST_FOREACH(const std::string& strBind, mapMultiArgs["-whitebind"]) {
for (const std::string& strBind : mapMultiArgs["-whitebind"]) {
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, 0, false))
return InitError(strprintf(_("Cannot resolve -whitebind address: '%s'"), strBind));
@ -1343,7 +1343,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}
if (mapArgs.count("-externalip")) {
BOOST_FOREACH(const std::string& strAddr, mapMultiArgs["-externalip"]) {
for (const std::string& strAddr : mapMultiArgs["-externalip"]) {
CService addrLocal(strAddr, GetListenPort(), fNameLookup);
if (!addrLocal.IsValid())
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr));
@ -1351,7 +1351,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}
}
BOOST_FOREACH(const std::string& strDest, mapMultiArgs["-seednode"])
for (const std::string& strDest : mapMultiArgs["-seednode"])
AddOneShot(strDest);
#if ENABLE_ZMQ
@ -1655,7 +1655,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
std::vector<fs::path> vImportFiles;
if (mapArgs.count("-loadblock"))
{
BOOST_FOREACH(const std::string& strFile, mapMultiArgs["-loadblock"])
for (const std::string& strFile : mapMultiArgs["-loadblock"])
vImportFiles.push_back(strFile);
}
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));

View File

@ -374,7 +374,7 @@ void FinalizeNode(NodeId nodeid) {
AddressCurrentlyConnected(state->address);
}
BOOST_FOREACH(const QueuedBlock& entry, state->vBlocksInFlight)
for (const QueuedBlock& entry : state->vBlocksInFlight)
mapBlocksInFlight.erase(entry.hash);
EraseOrphansFor(nodeid);
nPreferredDownload -= state->fPreferredDownload;
@ -523,7 +523,7 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<CBl
// are not yet downloaded and not in flight to vBlocks. In the meantime, update
// pindexLastCommonBlock as long as all ancestors are already downloaded, or if it's
// already part of our chain (and therefore don't need it even if pruned).
BOOST_FOREACH(CBlockIndex* pindex, vToFetch) {
for (CBlockIndex* pindex : vToFetch) {
if (!pindex->IsValid(BLOCK_VALID_TREE)) {
// We consider the chain that this peer is on invalid.
return;
@ -563,7 +563,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);
}
@ -591,7 +591,7 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals)
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator)
{
// Find the first block the caller has in the main chain
BOOST_FOREACH(const uint256& hash, locator.vHave) {
for (const uint256& hash : locator.vHave) {
BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end())
{
@ -636,7 +636,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(c
mapOrphanTransactions[hash].tx = tx;
mapOrphanTransactions[hash].fromPeer = peer;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash);
LogPrint("mempool", "stored orphan tx %s (mapsz %u prevsz %u)\n", hash.ToString(),
@ -649,7 +649,7 @@ void static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.find(hash);
if (it == mapOrphanTransactions.end())
return;
BOOST_FOREACH(const CTxIn& txin, it->second.tx.vin)
for (const CTxIn& txin : it->second.tx.vin)
{
map<uint256, set<uint256> >::iterator itPrev = mapOrphanTransactionsByPrev.find(txin.prevout.hash);
if (itPrev == mapOrphanTransactionsByPrev.end())
@ -700,7 +700,7 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
return true;
if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
return true;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
if (!txin.IsFinal())
return false;
return true;
@ -753,11 +753,11 @@ bool CheckFinalTx(const CTransaction &tx, int flags)
unsigned int GetLegacySigOpCount(const CTransaction& tx)
{
unsigned int nSigOps = 0;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
{
nSigOps += txin.scriptSig.GetSigOpCount(false);
}
BOOST_FOREACH(const CTxOut& txout, tx.vout)
for (const CTxOut& txout : tx.vout)
{
nSigOps += txout.scriptPubKey.GetSigOpCount(false);
}
@ -1173,7 +1173,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,
return false;
} else {
// Ensure that zk-SNARKs verify
BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) {
for (const JSDescription &joinsplit : tx.vJoinSplit) {
if (!verifier.VerifySprout(joinsplit, tx.joinSplitPubKey)) {
return state.DoS(100, error("CheckTransaction(): joinsplit does not verify"),
REJECT_INVALID, "bad-txns-joinsplit-verification-failed");
@ -1253,7 +1253,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
// Check for negative or overflow output values
CAmount nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
for (const CTxOut& txout : tx.vout)
{
if (txout.nValue < 0)
return state.DoS(100, error("CheckTransaction(): txout.nValue negative"),
@ -1290,7 +1290,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
}
// Ensure that joinsplit values are well-formed
BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit)
for (const JSDescription& joinsplit : tx.vJoinSplit)
{
if (joinsplit.vpub_old < 0) {
return state.DoS(100, error("CheckTransaction(): joinsplit.vpub_old negative"),
@ -1354,7 +1354,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
// Check for duplicate inputs
set<COutPoint> vInOutPoints;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
{
if (vInOutPoints.count(txin.prevout))
return state.DoS(100, error("CheckTransaction(): duplicate inputs"),
@ -1365,9 +1365,9 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
// Check for duplicate joinsplit nullifiers in this transaction
{
set<uint256> vJoinSplitNullifiers;
BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit)
for (const JSDescription& joinsplit : tx.vJoinSplit)
{
BOOST_FOREACH(const uint256& nf, joinsplit.nullifiers)
for (const uint256& nf : joinsplit.nullifiers)
{
if (vJoinSplitNullifiers.count(nf))
return state.DoS(100, error("CheckTransaction(): duplicate nullifiers"),
@ -1381,7 +1381,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
// Check for duplicate sapling nullifiers in this transaction
{
set<uint256> vSaplingNullifiers;
BOOST_FOREACH(const SpendDescription& spend_desc, tx.vShieldedSpend)
for (const SpendDescription& spend_desc : tx.vShieldedSpend)
{
if (vSaplingNullifiers.count(spend_desc.nullifier))
return state.DoS(100, error("CheckTransaction(): duplicate nullifiers"),
@ -1410,7 +1410,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
}
else
{
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
if (txin.prevout.IsNull())
return state.DoS(10, error("CheckTransaction(): prevout is null"),
REJECT_INVALID, "bad-txns-prevout-null");
@ -1517,8 +1517,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
return false;
}
}
BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) {
for (const JSDescription &joinsplit : tx.vJoinSplit) {
for (const uint256 &nf : joinsplit.nullifiers) {
if (pool.nullifierExists(nf, SPROUT)) {
return false;
}
@ -1548,7 +1548,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
// do all inputs exist?
// Note that this does not check for the presence of actual outputs (see the next check for that),
// and only helps with filling in pfMissingInputs (to determine missing vs spent).
BOOST_FOREACH(const CTxIn txin, tx.vin) {
for (const CTxIn txin : tx.vin) {
if (!view.HaveCoins(txin.prevout.hash)) {
if (pfMissingInputs)
*pfMissingInputs = true;
@ -1607,7 +1607,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
// 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 CCoins *coins = view.AccessCoins(txin.prevout.hash);
if (coins->IsCoinBase()) {
fSpendsCoinbase = true;
@ -1824,7 +1824,7 @@ bool GetTransaction(const uint256& hash, CTransaction& txOut, const Consensus::P
if (pindexSlow) {
CBlock block;
if (ReadBlockFromDisk(block, pindexSlow, consensusParams)) {
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
for (const CTransaction &tx : block.vtx) {
if (tx.GetHash() == hash) {
txOut = tx;
hashBlock = pindexSlow->GetBlockHash();
@ -2152,7 +2152,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) {
CCoinsModifier coins = inputs.ModifyCoins(txin.prevout.hash);
unsigned nPos = txin.prevout.n;
@ -2827,7 +2827,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
// Do not allow blocks that contain transactions which 'overwrite' older transactions,
// unless those are already completely spent.
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
for (const CTransaction& tx : block.vtx) {
const CCoins* coins = view.AccessCoins(tx.GetHash());
if (coins && !coins->IsPruned())
return state.DoS(100, error("ConnectBlock(): tried to overwrite transaction"),
@ -2995,15 +2995,15 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
}
UpdateCoins(tx, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight);
BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256 &note_commitment, joinsplit.commitments) {
for (const JSDescription &joinsplit : tx.vJoinSplit) {
for (const uint256 &note_commitment : joinsplit.commitments) {
// Insert the note commitments into our temporary tree.
sprout_tree.append(note_commitment);
}
}
BOOST_FOREACH(const OutputDescription &outputDescription, tx.vShieldedOutput) {
for (const OutputDescription &outputDescription : tx.vShieldedOutput) {
sapling_tree.append(outputDescription.cmu);
}
@ -3359,7 +3359,7 @@ bool static DisconnectTip(CValidationState &state, const CChainParams& chainpara
if (!fBare) {
// Resurrect mempool transactions from the disconnected block.
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
for (const CTransaction &tx : block.vtx) {
// ignore validation errors in resurrected transactions
list<CTransaction> removed;
CValidationState stateDummy;
@ -3707,7 +3707,7 @@ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams,
nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints());
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
if (chainActive.Height() > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate))
pnode->PushInventory(CInv(MSG_BLOCK, hashNewTip));
}
@ -4135,12 +4135,12 @@ bool CheckBlock(const CBlock& block,
if (!fCheckTransactions) return true;
// Check transactions
BOOST_FOREACH(const CTransaction& tx, block.vtx)
for (const CTransaction& tx : block.vtx)
if (!CheckTransaction(tx, state, verifier))
return error("CheckBlock(): CheckTransaction failed");
unsigned int nSigOps = 0;
BOOST_FOREACH(const CTransaction& tx, block.vtx)
for (const CTransaction& tx : block.vtx)
{
nSigOps += GetLegacySigOpCount(tx);
}
@ -4227,7 +4227,7 @@ bool ContextualCheckBlock(
if (fCheckTransactions) {
// Check that all transactions are finalized
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
for (const CTransaction& tx : block.vtx) {
// Check transaction contextually against consensus rules at block height
if (!ContextualCheckTransaction(tx, state, chainparams, nHeight, true)) {
@ -4273,7 +4273,7 @@ bool ContextualCheckBlock(
// first subsidy halving block, which occurs at halving_interval + slow_start_shift.
bool found = false;
BOOST_FOREACH(const CTxOut& output, block.vtx[0].vout) {
for (const CTxOut& output : block.vtx[0].vout) {
if (output.scriptPubKey == chainparams.GetFoundersRewardScriptAtHeight(nHeight)) {
if (output.nValue == (GetBlockSubsidy(nHeight, consensusParams) / 5)) {
found = true;
@ -4487,7 +4487,7 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams,
uint64_t CalculateCurrentUsage()
{
uint64_t retval = 0;
BOOST_FOREACH(const CBlockFileInfo &file, vinfoBlockFile) {
for (const CBlockFileInfo &file : vinfoBlockFile) {
retval += file.nSize + file.nUndoSize;
}
return retval;
@ -4662,13 +4662,13 @@ bool static LoadBlockIndexDB()
// Calculate nChainWork
vector<pair<int, CBlockIndex*> > 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(make_pair(pindex->nHeight, pindex));
}
sort(vSortedByHeight.begin(), vSortedByHeight.end());
BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
for (const PAIRTYPE(int, CBlockIndex*)& item : vSortedByHeight)
{
CBlockIndex* pindex = item.second;
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
@ -4754,7 +4754,7 @@ bool static LoadBlockIndexDB()
// Check presence of blk files
LogPrintf("Checking all blk files are present...\n");
set<int> 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) {
@ -4801,7 +4801,7 @@ bool static LoadBlockIndexDB()
}
// Fill in-memory data
BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex)
for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex)
{
CBlockIndex* pindex = item.second;
// - This relationship will always be true even if pprev has multiple
@ -5121,7 +5121,7 @@ void UnloadBlockIndex()
mapNodeState.clear();
recentRejects.reset(NULL);
BOOST_FOREACH(BlockMap::value_type& entry, mapBlockIndex) {
for (BlockMap::value_type& entry : mapBlockIndex) {
delete entry.second;
}
mapBlockIndex.clear();
@ -5582,7 +5582,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
// Thus, the protocol spec specified allows for us to provide duplicate txn here,
// however we MUST always provide at least what the remote peer needs
typedef std::pair<unsigned int, uint256> PairType;
BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn)
for (PairType& pair : merkleBlock.vMatchedTxn)
if (!pfrom->setInventoryKnown.count(CInv(MSG_TX, pair.second)))
pfrom->PushMessage("tx", block.vtx[pair.first]);
}
@ -5795,7 +5795,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// Relay alerts
{
LOCK(cs_mapAlerts);
BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts)
item.second.RelayTo(pfrom);
}
@ -5872,7 +5872,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
vector<CAddress> vAddrOk;
int64_t nNow = GetTime();
int64_t nSince = nNow - 10 * 60;
BOOST_FOREACH(CAddress& addr, vAddr)
for (CAddress& addr : vAddr)
{
boost::this_thread::interruption_point();
@ -5895,7 +5895,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
hashRand = Hash(BEGIN(hashRand), END(hashRand));
multimap<uint256, CNode*> mapMix;
FastRandomContext insecure_rand;
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
{
if (pnode->nVersion < CADDR_TIME_VERSION)
continue;
@ -6175,7 +6175,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
}
BOOST_FOREACH(uint256 hash, vEraseQueue)
for (uint256 hash : vEraseQueue)
EraseOrphanTx(hash);
}
// TODO: currently, prohibit joinsplits and shielded spends/outputs from entering mapOrphans
@ -6252,7 +6252,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
CBlockIndex *pindexLast = NULL;
BOOST_FOREACH(const CBlockHeader& header, headers) {
for (const CBlockHeader& header : headers) {
CValidationState state;
if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) {
Misbehaving(pfrom->GetId(), 20);
@ -6330,7 +6330,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
pfrom->vAddrToSend.clear();
vector<CAddress> vAddr = addrman.GetAddr();
FastRandomContext insecure_rand;
BOOST_FOREACH(const CAddress &addr, vAddr)
for (const CAddress &addr : vAddr)
pfrom->PushAddress(addr, insecure_rand);
}
@ -6344,7 +6344,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
std::vector<uint256> vtxid;
mempool.queryHashes(vtxid);
vector<CInv> vInv;
BOOST_FOREACH(uint256& hash, vtxid) {
for (uint256& hash : vtxid) {
CTransaction tx;
bool fInMemPool = mempool.lookup(hash, tx);
if (fInMemPool && IsExpiringSoonTx(tx, currentHeight + 1)) {
@ -6461,7 +6461,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
pfrom->setKnown.insert(alertHash);
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
alert.RelayTo(pnode);
}
}
@ -6750,7 +6750,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
if (!IsInitialBlockDownload(chainParams) && (GetTime() - nLastRebroadcast > 24 * 60 * 60))
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
{
// Periodically clear addrKnown to allow refresh broadcasts
if (nLastRebroadcast)
@ -6770,7 +6770,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
{
vector<CAddress> 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()))
{
@ -6805,7 +6805,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
state.fShouldBan = false;
}
BOOST_FOREACH(const CBlockReject& reject, state.rejects)
for (const CBlockReject& reject : state.rejects)
pto->PushMessage("reject", (string)"block", reject.chRejectCode, reject.strRejectReason, reject.hashBlock);
state.rejects.clear();
@ -6841,7 +6841,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
LOCK(pto->cs_inventory);
vInv.reserve(pto->vInventoryToSend.size());
vInvWait.reserve(pto->vInventoryToSend.size());
BOOST_FOREACH(const CInv& inv, pto->vInventoryToSend)
for (const CInv& inv : pto->vInventoryToSend)
{
if (pto->setInventoryKnown.count(inv))
continue;
@ -6920,7 +6920,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
vector<CBlockIndex*> vToDownload;
NodeId staller = -1;
FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller);
BOOST_FOREACH(CBlockIndex *pindex, vToDownload) {
for (CBlockIndex *pindex : vToDownload) {
vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash()));
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), consensusParams, pindex);
LogPrint("net", "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),

View File

@ -358,7 +358,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre
double dPriority = 0;
CAmount nTotalIn = 0;
bool fMissingInputs = false;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
{
// Read prev transaction
if (!view.HaveCoins(txin.prevout.hash))
@ -552,7 +552,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre
// Add transactions that depend on this one to the priority queue
if (mapDependers.count(hash))
{
BOOST_FOREACH(COrphan* porphan, mapDependers[hash])
for (COrphan* porphan : mapDependers[hash])
{
if (!porphan->setDependsOn.empty())
{

View File

@ -321,7 +321,7 @@ CCriticalSection CNode::cs_totalBytesSent;
CNode* 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;
@ -330,7 +330,7 @@ CNode* FindNode(const CNetAddr& ip)
CNode* 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;
@ -339,7 +339,7 @@ CNode* FindNode(const CSubNet& subNet)
CNode* FindNode(const std::string& addrName)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
if (pnode->addrName == addrName)
return (pnode);
return NULL;
@ -348,7 +348,7 @@ CNode* FindNode(const std::string& addrName)
CNode* 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;
@ -525,7 +525,7 @@ CCriticalSection CNode::cs_vWhitelistedRange;
bool CNode::IsWhitelistedRange(const CNetAddr &addr) {
LOCK(cs_vWhitelistedRange);
BOOST_FOREACH(const CSubNet& subnet, vWhitelistedRange) {
for (const CSubNet& subnet : vWhitelistedRange) {
if (subnet.Match(addr))
return true;
}
@ -797,7 +797,7 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) {
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode *node, vNodes) {
for (CNode *node : vNodes) {
if (node->fWhitelisted)
continue;
if (!node->fInbound)
@ -877,7 +877,7 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) {
unsigned int nMostConnections = 0;
int64_t nMostConnectionsTime = 0;
std::map<std::vector<unsigned char>, std::vector<CNodeRef> > mapAddrCounts;
BOOST_FOREACH(const CNodeRef &node, vEvictionCandidates) {
for (const CNodeRef &node : vEvictionCandidates) {
mapAddrCounts[node->addr.GetGroup()].push_back(node);
int64_t grouptime = mapAddrCounts[node->addr.GetGroup()][0]->nTimeConnected;
size_t groupsize = mapAddrCounts[node->addr.GetGroup()].size();
@ -919,7 +919,7 @@ static void AcceptConnection(const ListenSocket& hListenSocket) {
bool whitelisted = hListenSocket.whitelisted || CNode::IsWhitelistedRange(addr);
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
if (pnode->fInbound)
nInbound++;
}
@ -989,7 +989,7 @@ void ThreadSocketHandler()
LOCK(cs_vNodes);
// Disconnect unused nodes
vector<CNode*> vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy)
for (CNode* pnode : vNodesCopy)
{
if (pnode->fDisconnect ||
(pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty()))
@ -1015,7 +1015,7 @@ void ThreadSocketHandler()
{
// Delete disconnected nodes
list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected;
BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy)
for (CNode* pnode : vNodesDisconnectedCopy)
{
// wait until threads are done using it
if (pnode->GetRefCount() <= 0)
@ -1063,7 +1063,7 @@ void ThreadSocketHandler()
SOCKET hSocketMax = 0;
bool have_fds = false;
BOOST_FOREACH(const ListenSocket& hListenSocket, vhListenSocket) {
for (const ListenSocket& hListenSocket : vhListenSocket) {
FD_SET(hListenSocket.socket, &fdsetRecv);
hSocketMax = max(hSocketMax, hListenSocket.socket);
have_fds = true;
@ -1071,7 +1071,7 @@ void ThreadSocketHandler()
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
{
if (pnode->hSocket == INVALID_SOCKET)
continue;
@ -1132,7 +1132,7 @@ void ThreadSocketHandler()
//
// Accept new connections
//
BOOST_FOREACH(const ListenSocket& hListenSocket, vhListenSocket)
for (const ListenSocket& hListenSocket : vhListenSocket)
{
if (hListenSocket.socket != INVALID_SOCKET && FD_ISSET(hListenSocket.socket, &fdsetRecv))
{
@ -1147,10 +1147,10 @@ void ThreadSocketHandler()
{
LOCK(cs_vNodes);
vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy)
for (CNode* pnode : vNodesCopy)
pnode->AddRef();
}
BOOST_FOREACH(CNode* pnode, vNodesCopy)
for (CNode* pnode : vNodesCopy)
{
boost::this_thread::interruption_point();
@ -1242,7 +1242,7 @@ void ThreadSocketHandler()
}
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodesCopy)
for (CNode* pnode : vNodesCopy)
pnode->Release();
}
}
@ -1268,7 +1268,7 @@ void ThreadDNSAddressSeed()
LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
BOOST_FOREACH(const CDNSSeedData &seed, vSeeds) {
for (const CDNSSeedData &seed : vSeeds) {
if (HaveNameProxy()) {
AddOneShot(seed.host);
} else {
@ -1276,7 +1276,7 @@ void ThreadDNSAddressSeed()
vector<CAddress> vAdd;
if (LookupHost(seed.host.c_str(), vIPs))
{
BOOST_FOREACH(const CNetAddr& ip, vIPs)
for (const CNetAddr& ip : vIPs)
{
int nOneDay = 24*3600;
CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()));
@ -1340,7 +1340,7 @@ void ThreadOpenConnections()
for (int64_t nLoop = 0;; nLoop++)
{
ProcessOneShot();
BOOST_FOREACH(const std::string& strAddr, mapMultiArgs["-connect"])
for (const std::string& strAddr : mapMultiArgs["-connect"])
{
CAddress addr;
OpenNetworkConnection(addr, NULL, strAddr.c_str());
@ -1385,7 +1385,7 @@ void ThreadOpenConnections()
set<vector<unsigned char> > setConnected;
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes) {
for (CNode* pnode : vNodes) {
if (!pnode->fInbound) {
setConnected.insert(pnode->addr.GetGroup());
nOutbound++;
@ -1443,10 +1443,10 @@ void ThreadOpenAddedConnections()
list<string> lAddresses(0);
{
LOCK(cs_vAddedNodes);
BOOST_FOREACH(const std::string& strAddNode, vAddedNodes)
for (const std::string& strAddNode : vAddedNodes)
lAddresses.push_back(strAddNode);
}
BOOST_FOREACH(const std::string& strAddNode, lAddresses) {
for (const std::string& strAddNode : lAddresses) {
CAddress addr;
CSemaphoreGrant grant(*semOutbound);
OpenNetworkConnection(addr, &grant, strAddNode.c_str());
@ -1461,19 +1461,19 @@ void ThreadOpenAddedConnections()
list<string> lAddresses(0);
{
LOCK(cs_vAddedNodes);
BOOST_FOREACH(const std::string& strAddNode, vAddedNodes)
for (const std::string& strAddNode : vAddedNodes)
lAddresses.push_back(strAddNode);
}
list<vector<CService> > lservAddressesToAdd(0);
BOOST_FOREACH(const std::string& strAddNode, lAddresses) {
for (const std::string& strAddNode : lAddresses) {
vector<CService> vservNode(0);
if(Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0))
{
lservAddressesToAdd.push_back(vservNode);
{
LOCK(cs_setservAddNodeAddresses);
BOOST_FOREACH(const CService& serv, vservNode)
for (const CService& serv : vservNode)
setservAddNodeAddresses.insert(serv);
}
}
@ -1482,9 +1482,9 @@ void ThreadOpenAddedConnections()
// (keeping in mind that addnode entries can have many IPs if fNameLookup)
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
for (list<vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++)
BOOST_FOREACH(const CService& addrNode, *(it))
for (const CService& addrNode : *(it))
if (pnode->addr == addrNode)
{
it = lservAddressesToAdd.erase(it);
@ -1492,7 +1492,7 @@ void ThreadOpenAddedConnections()
break;
}
}
BOOST_FOREACH(vector<CService>& vserv, lservAddressesToAdd)
for (vector<CService>& vserv : lservAddressesToAdd)
{
CSemaphoreGrant grant(*semOutbound);
OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant);
@ -1544,7 +1544,7 @@ void ThreadMessageHandler()
{
LOCK(cs_vNodes);
vNodesCopy = vNodes;
BOOST_FOREACH(CNode* pnode, vNodesCopy) {
for (CNode* pnode : vNodesCopy) {
pnode->AddRef();
}
}
@ -1556,7 +1556,7 @@ void ThreadMessageHandler()
bool fSleep = true;
BOOST_FOREACH(CNode* pnode, vNodesCopy)
for (CNode* pnode : vNodesCopy)
{
if (pnode->fDisconnect)
continue;
@ -1593,7 +1593,7 @@ void ThreadMessageHandler()
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodesCopy)
for (CNode* pnode : vNodesCopy)
pnode->Release();
}
@ -1718,7 +1718,7 @@ void static Discover(boost::thread_group& threadGroup)
vector<CNetAddr> vaddr;
if (LookupHost(pszHostName, vaddr))
{
BOOST_FOREACH (const CNetAddr &addr, vaddr)
for (const CNetAddr &addr : vaddr)
{
if (AddLocal(addr, LOCAL_IF))
LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString());
@ -1831,18 +1831,18 @@ public:
~CNetCleanup()
{
// Close sockets
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
if (pnode->hSocket != INVALID_SOCKET)
CloseSocket(pnode->hSocket);
BOOST_FOREACH(ListenSocket& hListenSocket, vhListenSocket)
for (ListenSocket& hListenSocket : vhListenSocket)
if (hListenSocket.socket != INVALID_SOCKET)
if (!CloseSocket(hListenSocket.socket))
LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError()));
// clean up some globals (to help leak detection)
BOOST_FOREACH(CNode *pnode, vNodes)
for (CNode *pnode : vNodes)
delete pnode;
BOOST_FOREACH(CNode *pnode, vNodesDisconnected)
for (CNode *pnode : vNodesDisconnected)
delete pnode;
vNodes.clear();
vNodesDisconnected.clear();
@ -1891,7 +1891,7 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss)
vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));
}
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
{
if(!pnode->fRelayTxes)
continue;

View File

@ -374,7 +374,7 @@ public:
unsigned int GetTotalRecvSize()
{
unsigned int total = 0;
BOOST_FOREACH(const CNetMessage &msg, vRecvMsg)
for (const CNetMessage &msg : vRecvMsg)
total += msg.vRecv.size() + 24;
return total;
}
@ -386,7 +386,7 @@ public:
void SetRecvVersion(int nVersionIn)
{
nRecvVersion = nVersionIn;
BOOST_FOREACH(CNetMessage &msg, vRecvMsg)
for (CNetMessage &msg : vRecvMsg)
msg.SetVersion(nVersionIn);
}

View File

@ -81,7 +81,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const CChainParam
}
}
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
@ -102,7 +102,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const CChainParam
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;

View File

@ -153,7 +153,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();
}
@ -173,7 +173,7 @@ static bool rest_headers(HTTPRequest* req,
}
case RF_JSON: {
UniValue jsonHeaders(UniValue::VARR);
BOOST_FOREACH(const CBlockIndex *pindex, headers) {
for (const CBlockIndex *pindex : headers) {
jsonHeaders.push_back(blockheaderToJSON(pindex));
}
string strJSON = jsonHeaders.write() + "\n";
@ -562,7 +562,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
objGetUTXOResponse.pushKV("bitmap", bitmapStringRepresentation);
UniValue utxos(UniValue::VARR);
BOOST_FOREACH (const CCoin& coin, outs) {
for (const CCoin& coin : outs) {
UniValue utxo(UniValue::VOBJ);
utxo.pushKV("txvers", (int32_t)coin.nTxVer);
utxo.pushKV("height", (int32_t)coin.nHeight);

View File

@ -233,7 +233,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
result.pushKV("finalsaplingroot", blockindex->hashFinalSaplingRoot.GetHex());
result.pushKV("chainhistoryroot", blockindex->hashChainHistoryRoot.GetHex());
UniValue txs(UniValue::VARR);
BOOST_FOREACH(const CTransaction&tx, block.vtx)
for (const CTransaction&tx : block.vtx)
{
if(txDetails)
{
@ -323,7 +323,7 @@ UniValue mempoolToJSON(bool fVerbose = false)
{
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);
@ -335,14 +335,14 @@ UniValue mempoolToJSON(bool fVerbose = false)
info.pushKV("currentpriority", e.GetPriority(chainActive.Height()));
const CTransaction& tx = e.GetTx();
set<string> setDepends;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
{
if (mempool.exists(txin.prevout.hash))
setDepends.insert(txin.prevout.hash.ToString());
}
UniValue depends(UniValue::VARR);
BOOST_FOREACH(const string& dep, setDepends)
for (const string& dep : setDepends)
{
depends.push_back(dep);
}
@ -358,7 +358,7 @@ UniValue mempoolToJSON(bool fVerbose = false)
mempool.queryHashes(vtxid);
UniValue a(UniValue::VARR);
BOOST_FOREACH(const uint256& hash, vtxid)
for (const uint256& hash : vtxid)
a.push_back(hash.ToString());
return a;
@ -1151,9 +1151,9 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
known blocks, and successively remove blocks that appear as pprev
of another block. */
std::set<const CBlockIndex*, CompareBlocksByHeight> setTips;
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex)
for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex)
setTips.insert(item.second);
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex)
for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex)
{
const CBlockIndex* pprev = item.second->pprev;
if (pprev)
@ -1165,7 +1165,7 @@ UniValue getchaintips(const UniValue& params, bool fHelp)
/* Construct the output array. */
UniValue res(UniValue::VARR);
BOOST_FOREACH(const CBlockIndex* block, setTips)
for (const CBlockIndex* block : setTips)
{
UniValue obj(UniValue::VOBJ);
obj.pushKV("height", block->nHeight);

View File

@ -650,7 +650,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
UniValue transactions(UniValue::VARR);
map<uint256, int64_t> setTxIndex;
int i = 0;
BOOST_FOREACH (const CTransaction& tx, pblock->vtx) {
for (const CTransaction& tx : pblock->vtx) {
uint256 txHash = tx.GetHash();
setTxIndex[txHash] = i++;
@ -664,7 +664,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
entry.pushKV("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]);

View File

@ -482,7 +482,7 @@ UniValue setmocktime(const UniValue& params, bool fHelp)
SetMockTime(params[0].get_int64());
uint64_t t = GetTime();
BOOST_FOREACH(CNode* pnode, vNodes) {
for (CNode* pnode : vNodes) {
pnode->nLastSend = pnode->nLastRecv = t;
}

View File

@ -54,7 +54,7 @@ UniValue ping(const UniValue& params, bool fHelp)
// Request that each node send a ping during next message processing pass
LOCK2(cs_main, cs_vNodes);
BOOST_FOREACH(CNode* pNode, vNodes) {
for (CNode* pNode : vNodes) {
pNode->fPingQueued = true;
}
@ -67,7 +67,7 @@ static void CopyNodeStats(std::vector<CNodeStats>& vstats)
LOCK(cs_vNodes);
vstats.reserve(vNodes.size());
BOOST_FOREACH(CNode* pnode, vNodes) {
for (CNode* pnode : vNodes) {
CNodeStats stats;
pnode->copyStats(stats);
vstats.push_back(stats);
@ -121,7 +121,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp)
UniValue ret(UniValue::VARR);
BOOST_FOREACH(const CNodeStats& stats, vstats) {
for (const CNodeStats& stats : vstats) {
UniValue obj(UniValue::VOBJ);
CNodeStateStats statestats;
bool fStateStats = GetNodeStateStats(stats.nodeid, statestats);
@ -151,7 +151,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp)
obj.pushKV("synced_headers", statestats.nSyncHeight);
obj.pushKV("synced_blocks", statestats.nCommonHeight);
UniValue heights(UniValue::VARR);
BOOST_FOREACH(int height, statestats.vHeightInFlight) {
for (int height : statestats.vHeightInFlight) {
heights.push_back(height);
}
obj.pushKV("inflight", heights);
@ -275,14 +275,14 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp)
if (params.size() == 1)
{
LOCK(cs_vAddedNodes);
BOOST_FOREACH(const std::string& strAddNode, vAddedNodes)
for (const std::string& strAddNode : vAddedNodes)
laddedNodes.push_back(strAddNode);
}
else
{
string strNode = params[1].get_str();
LOCK(cs_vAddedNodes);
BOOST_FOREACH(const std::string& strAddNode, vAddedNodes) {
for (const std::string& strAddNode : vAddedNodes) {
if (strAddNode == strNode)
{
laddedNodes.push_back(strAddNode);
@ -296,7 +296,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp)
UniValue ret(UniValue::VARR);
if (!fDns)
{
BOOST_FOREACH (const std::string& strAddNode, laddedNodes) {
for (const std::string& strAddNode : laddedNodes) {
UniValue obj(UniValue::VOBJ);
obj.pushKV("addednode", strAddNode);
ret.push_back(obj);
@ -305,7 +305,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp)
}
list<pair<string, vector<CService> > > laddedAddreses(0);
BOOST_FOREACH(const std::string& strAddNode, laddedNodes) {
for (const std::string& strAddNode : laddedNodes) {
vector<CService> vservNode(0);
if(Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0))
laddedAddreses.push_back(make_pair(strAddNode, vservNode));
@ -327,11 +327,11 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp)
UniValue addresses(UniValue::VARR);
bool fConnected = false;
BOOST_FOREACH(const CService& addrNode, it->second) {
for (const CService& addrNode : it->second) {
bool fFound = false;
UniValue node(UniValue::VOBJ);
node.pushKV("address", addrNode.ToString());
BOOST_FOREACH(CNode* pnode, vNodes) {
for (CNode* pnode : vNodes) {
if (pnode->addr == addrNode)
{
fFound = true;
@ -478,7 +478,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp)
UniValue localAddresses(UniValue::VARR);
{
LOCK(cs_mapLocalHost);
BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost)
for (const PAIRTYPE(CNetAddr, LocalServiceInfo) &item : mapLocalHost)
{
UniValue rec(UniValue::VOBJ);
rec.pushKV("address", item.first.ToString());

View File

@ -76,7 +76,7 @@ UniValue TxJoinSplitToJSON(const CTransaction& tx) {
{
UniValue nullifiers(UniValue::VARR);
BOOST_FOREACH(const uint256 nf, jsdescription.nullifiers) {
for (const uint256 nf : jsdescription.nullifiers) {
nullifiers.push_back(nf.GetHex());
}
joinsplit.pushKV("nullifiers", nullifiers);
@ -84,7 +84,7 @@ UniValue TxJoinSplitToJSON(const CTransaction& tx) {
{
UniValue commitments(UniValue::VARR);
BOOST_FOREACH(const uint256 commitment, jsdescription.commitments) {
for (const uint256 commitment : jsdescription.commitments) {
commitments.push_back(commitment.GetHex());
}
joinsplit.pushKV("commitments", commitments);
@ -95,7 +95,7 @@ UniValue TxJoinSplitToJSON(const CTransaction& tx) {
{
UniValue macs(UniValue::VARR);
BOOST_FOREACH(const uint256 mac, jsdescription.macs) {
for (const uint256 mac : jsdescription.macs) {
macs.push_back(mac.GetHex());
}
joinsplit.pushKV("macs", macs);
@ -166,7 +166,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
KeyIO keyIO(Params());
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()));
@ -487,7 +487,7 @@ UniValue gettxoutproof(const UniValue& params, bool fHelp)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
unsigned int ntxFound = 0;
BOOST_FOREACH(const CTransaction&tx, block.vtx)
for (const CTransaction&tx : block.vtx)
if (setTxids.count(tx.GetHash()))
ntxFound++;
if (ntxFound != setTxids.size())
@ -528,7 +528,7 @@ UniValue verifytxoutproof(const UniValue& params, bool fHelp)
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;
}
@ -906,7 +906,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
CCoinsViewMemPool viewMempool(&viewChain, mempool);
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) {
for (const CTxIn& txin : mergedTx.vin) {
const uint256& prevHash = txin.prevout.hash;
CCoins coins;
view.AccessCoins(prevHash); // this is certainly allowed to fail
@ -1052,7 +1052,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata, consensusBranchId);
// ... and merge in other signatures:
BOOST_FOREACH(const CMutableTransaction& txv, txVariants) {
for (const CMutableTransaction& txv : txVariants) {
sigdata = CombineSignatures(prevPubKey, TransactionSignatureChecker(&txConst, i, amount), sigdata, DataFromTransaction(txv, i), consensusBranchId);
}

View File

@ -77,7 +77,7 @@ void RPCTypeCheck(const UniValue& params,
bool fAllowNull)
{
size_t i = 0;
BOOST_FOREACH(UniValue::VType t, typesExpected)
for (UniValue::VType t : typesExpected)
{
if (params.size() <= i)
break;
@ -97,7 +97,7 @@ void RPCTypeCheckObj(const UniValue& o,
const map<string, UniValue::VType>& typesExpected,
bool fAllowNull)
{
BOOST_FOREACH(const PAIRTYPE(string, UniValue::VType)& t, typesExpected)
for (const PAIRTYPE(string, UniValue::VType)& t : typesExpected)
{
const UniValue& v = find_value(o, t.first);
if (!fAllowNull && v.isNull())
@ -178,7 +178,7 @@ std::string CRPCTable::help(const std::string& strCommand) const
vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second));
sort(vCommands.begin(), vCommands.end());
BOOST_FOREACH(const PAIRTYPE(string, const CRPCCommand*)& command, vCommands)
for (const PAIRTYPE(string, const CRPCCommand*)& command : vCommands)
{
const CRPCCommand *pcmd = command.second;
string strMethod = pcmd->name;

View File

@ -39,7 +39,7 @@ typedef vector<unsigned char> valtype;
unsigned int HaveKeys(const vector<valtype>& 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))

View File

@ -118,7 +118,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
static CScript PushAll(const vector<valtype>& values)
{
CScript result;
BOOST_FOREACH(const valtype& v, values) {
for (const valtype& v : values) {
if (v.size() == 0) {
result << OP_0;
} else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) {
@ -211,12 +211,12 @@ static vector<valtype> CombineMultisig(const CScript& scriptPubKey, const BaseSi
{
// Combine all the signatures we've got:
set<valtype> 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);
@ -227,7 +227,7 @@ static vector<valtype> CombineMultisig(const CScript& scriptPubKey, const BaseSi
unsigned int nSigsRequired = vSolutions.front()[0];
unsigned int nPubKeys = vSolutions.size()-2;
map<valtype, valtype> sigs;
BOOST_FOREACH(const valtype& sig, allsigs)
for (const valtype& sig : allsigs)
{
for (unsigned int i = 0; i < nPubKeys; i++)
{

View File

@ -270,7 +270,7 @@ CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& 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;

View File

@ -99,7 +99,7 @@ void ThreadSendAlert()
// alert.setSubVer.insert(std::string("/MagicBean:0.7.2/"));
const std::vector<std::string> useragents = {}; //{"MagicBean", "BeanStalk", "AppleSeed", "EleosZcash"};
BOOST_FOREACH(const std::string& useragent, useragents) {
for (const std::string& useragent : useragents) {
}
// Sanity check
@ -161,7 +161,7 @@ void ThreadSendAlert()
int nSent = 0;
{
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (CNode* pnode : vNodes)
{
if (alert2.RelayTo(pnode))
{

View File

@ -76,7 +76,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
LogPrintf("POTENTIAL DEADLOCK DETECTED\n");
LogPrintf("Previous lock order was:\n");
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s2) {
for (const PAIRTYPE(void*, CLockLocation) & i : s2) {
if (i.first == mismatch.first) {
LogPrintf(" (1)");
if (!firstLocked && secondLocked && i.second.fTry)
@ -94,7 +94,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
firstLocked = false;
secondLocked = false;
LogPrintf("Current lock order is:\n");
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s1) {
for (const PAIRTYPE(void*, CLockLocation) & i : s1) {
if (i.first == mismatch.first) {
LogPrintf(" (1)");
if (!firstLocked && secondLocked && i.second.fTry)
@ -122,7 +122,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
(*lockstack).push_back(std::make_pair(c, locklocation));
if (!fTry) {
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, (*lockstack)) {
for (const PAIRTYPE(void*, CLockLocation) & i : (*lockstack)) {
if (i.first == c)
break;
@ -159,14 +159,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());

View File

@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(AlertApplies)
SetMockTime(11);
const std::vector<unsigned char>& alertKey = Params(CBaseChainParams::MAIN).AlertKey();
BOOST_FOREACH(const CAlert& alert, alerts)
for (const CAlert& alert : alerts)
{
BOOST_CHECK(alert.CheckSignature(alertKey));
}
@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(AlertNotify)
mapArgs["-alertnotify"] = std::string("echo %s >> ") + temp.string();
BOOST_FOREACH(CAlert alert, alerts)
for (CAlert alert : alerts)
alert.ProcessAlert(alertKey, false);
std::vector<std::string> r = read_lines(temp);

View File

@ -85,7 +85,7 @@ void RunTest(const TestVector &test) {
key.SetMaster(&seed[0], seed.size());
pubkey = key.Neuter();
KeyIO keyIO(Params());
BOOST_FOREACH(const TestDerivation &derive, test.vDerive) {
for (const TestDerivation &derive : test.vDerive) {
unsigned char data[74];
key.Encode(data);
pubkey.Encode(data);

View File

@ -838,7 +838,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
missed_an_entry = true;
}
}
BOOST_FOREACH(const CCoinsViewCacheTest *test, stack) {
for (const CCoinsViewCacheTest *test : stack) {
test->SelfTest();
}
}

View File

@ -25,7 +25,7 @@ static void ResetArgs(const std::string& strArg)
// Convert to char*:
std::vector<const char*> vecChar;
BOOST_FOREACH(std::string& s, vecArg)
for (std::string& s : vecArg)
vecChar.push_back(s.c_str());
ParseParameters(vecChar.size(), &vecChar[0]);

View File

@ -458,7 +458,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
SetMockTime(0);
mempool.clear();
BOOST_FOREACH(CTransaction *tx, txFirst)
for (CTransaction *tx : txFirst)
delete tx;
fCheckpointsEnabled = true;

View File

@ -53,18 +53,18 @@ BOOST_AUTO_TEST_CASE(mruset_test)
mruset<int> mru2 = mru; // Also try making a copy
// Check that all elements that should be in there, are in there.
BOOST_FOREACH(int x, rep) {
for (int x : rep) {
BOOST_CHECK(mru.count(x));
BOOST_CHECK(mru2.count(x));
}
// Check that all elements that are in there, should be in there.
BOOST_FOREACH(int x, mru) {
for (int x : mru) {
BOOST_CHECK(all.count(x));
}
// Check that all elements that are in there, should be in there.
BOOST_FOREACH(int x, mru2) {
for (int x : mru2) {
BOOST_CHECK(all.count(x));
}

View File

@ -30,7 +30,7 @@ sign_multisig(CScript scriptPubKey, vector<CKey> keys, CTransaction transaction,
CScript result;
result << OP_0; // CHECKMULTISIG bug workaround
BOOST_FOREACH(const CKey &key, keys)
for (const CKey &key : keys)
{
vector<unsigned char> vchSig;
BOOST_CHECK(key.Sign(hash, vchSig));

View File

@ -40,13 +40,13 @@ class prevector_tester {
BOOST_CHECK(pretype(real_vector.begin(), real_vector.end()) == pre_vector);
BOOST_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) {
BOOST_CHECK(v == real_vector[pos++]);
}
BOOST_REVERSE_FOREACH(const T& v, pre_vector) {
BOOST_CHECK(v == real_vector[--pos]);
}
BOOST_FOREACH(const T& v, const_pre_vector) {
for (const T& v : const_pre_vector) {
BOOST_CHECK(v == real_vector[pos++]);
}
BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) {

View File

@ -532,7 +532,7 @@ BOOST_AUTO_TEST_CASE(script_build)
std::string strGood;
std::string strBad;
BOOST_FOREACH(TestBuilder& test, good) {
for (TestBuilder& test : good) {
test.Test(true);
std::string str = test.GetJSON().write();
#ifndef UPDATE_JSON_TESTS
@ -542,7 +542,7 @@ BOOST_AUTO_TEST_CASE(script_build)
#endif
strGood += str + ",\n";
}
BOOST_FOREACH(TestBuilder& test, bad) {
for (TestBuilder& test : bad) {
test.Test(false);
std::string str = test.GetJSON().write();
#ifndef UPDATE_JSON_TESTS
@ -673,7 +673,7 @@ sign_multisig(CScript scriptPubKey, std::vector<CKey> keys, CTransaction transac
// and vice-versa)
//
result << OP_0;
BOOST_FOREACH(const CKey &key, keys)
for (const CKey &key : keys)
{
vector<unsigned char> vchSig;
BOOST_CHECK(key.Sign(hash, vchSig));

View File

@ -156,7 +156,7 @@ TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransaction>&
// Replace mempool-selected txns with just coinbase plus passed-in txns:
block.vtx.resize(1);
BOOST_FOREACH(const CMutableTransaction& tx, txns)
for (const CMutableTransaction& tx : txns)
block.vtx.push_back(tx);
// IncrementExtraNonce creates a valid coinbase and merkleRoot
unsigned int extraNonce = 0;

View File

@ -46,7 +46,7 @@ unsigned int ParseScriptFlags(std::string strFlags)
std::vector<std::string> 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 << "'");

View File

@ -489,7 +489,7 @@ void TorController::add_onion_cb(TorControlConnection& conn, const TorControlRep
{
if (reply.code == 250) {
LogPrint("tor", "tor: ADD_ONION successful\n");
BOOST_FOREACH(const std::string &s, reply.lines) {
for (const std::string &s : reply.lines) {
std::map<std::string,std::string> m = ParseTorReplyMapping(s);
std::map<std::string,std::string>::iterator i;
if ((i = m.find("ServiceID")) != m.end())
@ -619,7 +619,7 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl
* 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<std::string,std::string> l = SplitTorReplyLine(s);
if (l.first == "AUTH") {
std::map<std::string,std::string> m = ParseTorReplyMapping(l.second);
@ -636,7 +636,7 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl
}
}
}
BOOST_FOREACH(const std::string &s, methods) {
for (const std::string &s : methods) {
LogPrint("tor", "tor: Supported authentication method: %s\n", s);
}
// Prefer NULL, otherwise SAFECOOKIE. If a password is provided, use HASHEDPASSWORD

View File

@ -111,8 +111,8 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
nRecentlyAddedSequence += 1;
for (unsigned int i = 0; i < tx.vin.size(); i++)
mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i);
BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) {
for (const JSDescription &joinsplit : tx.vJoinSplit) {
for (const uint256 &nf : joinsplit.nullifiers) {
mapSproutNullifiers[nf] = &tx;
}
}
@ -269,10 +269,10 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
}
}
mapRecentlyAddedTx.erase(hash);
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
mapNextTx.erase(txin.prevout);
BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256& nf, joinsplit.nullifiers) {
for (const JSDescription& joinsplit : tx.vJoinSplit) {
for (const uint256& nf : joinsplit.nullifiers) {
mapSproutNullifiers.erase(nf);
}
}
@ -308,7 +308,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
if (!CheckFinalTx(tx, flags)) {
transactionsToRemove.push_back(tx);
} 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;
@ -321,7 +321,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
}
}
}
BOOST_FOREACH(const CTransaction& tx, transactionsToRemove) {
for (const CTransaction& tx : transactionsToRemove) {
list<CTransaction> removed;
remove(tx, removed, true);
}
@ -341,7 +341,7 @@ void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot, ShieldedType type)
const CTransaction& tx = it->GetTx();
switch (type) {
case SPROUT:
BOOST_FOREACH(const JSDescription& joinsplit, tx.vJoinSplit) {
for (const JSDescription& joinsplit : tx.vJoinSplit) {
if (joinsplit.anchor == invalidRoot) {
transactionsToRemove.push_back(tx);
break;
@ -349,7 +349,7 @@ void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot, ShieldedType type)
}
break;
case SAPLING:
BOOST_FOREACH(const SpendDescription& spendDescription, tx.vShieldedSpend) {
for (const SpendDescription& spendDescription : tx.vShieldedSpend) {
if (spendDescription.anchor == invalidRoot) {
transactionsToRemove.push_back(tx);
break;
@ -362,7 +362,7 @@ void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot, ShieldedType type)
}
}
BOOST_FOREACH(const CTransaction& tx, transactionsToRemove) {
for (const CTransaction& tx : transactionsToRemove) {
list<CTransaction> removed;
remove(tx, removed, true);
}
@ -373,7 +373,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>
// Remove transactions which depend on inputs of tx, recursively
list<CTransaction> result;
LOCK(cs);
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
for (const CTxIn &txin : tx.vin) {
std::map<COutPoint, CInPoint>::iterator it = mapNextTx.find(txin.prevout);
if (it != mapNextTx.end()) {
const CTransaction &txConflict = *it->second.ptx;
@ -384,8 +384,8 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>
}
}
BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) {
for (const JSDescription &joinsplit : tx.vJoinSplit) {
for (const uint256 &nf : joinsplit.nullifiers) {
std::map<uint256, const CTransaction*>::iterator it = mapSproutNullifiers.find(nf);
if (it != mapSproutNullifiers.end()) {
const CTransaction &txConflict = *it->second;
@ -436,7 +436,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned i
{
LOCK(cs);
std::vector<CTxMemPoolEntry> entries;
BOOST_FOREACH(const CTransaction& tx, vtx)
for (const CTransaction& tx : vtx)
{
uint256 hash = tx.GetHash();
@ -444,7 +444,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned i
if (i != mapTx.end())
entries.push_back(*i);
}
BOOST_FOREACH(const CTransaction& tx, vtx)
for (const CTransaction& tx : vtx)
{
std::list<CTransaction> dummy;
remove(tx, dummy, false);
@ -511,7 +511,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
innerUsage += it->DynamicMemoryUsage();
const CTransaction& tx = it->GetTx();
bool fDependsWait = false;
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
for (const CTxIn &txin : tx.vin) {
// Check that every mempool transaction's inputs refer to available coins, or other mempool tx's.
indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
if (it2 != mapTx.end()) {
@ -532,8 +532,8 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;
BOOST_FOREACH(const JSDescription &joinsplit, tx.vJoinSplit) {
BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) {
for (const JSDescription &joinsplit : tx.vJoinSplit) {
for (const uint256 &nf : joinsplit.nullifiers) {
assert(!pcoins->GetNullifier(nf, SPROUT));
}
@ -545,7 +545,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
assert(pcoins->GetSproutAnchorAt(joinsplit.anchor, tree));
}
BOOST_FOREACH(const uint256& commitment, joinsplit.commitments)
for (const uint256& commitment : joinsplit.commitments)
{
tree.append(commitment);
}

View File

@ -553,7 +553,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
}
hdSeed = HDSeed();
}
BOOST_FOREACH(KeyMap::value_type& mKey, mapKeys)
for (KeyMap::value_type& mKey : mapKeys)
{
const CKey &key = mKey.second;
CPubKey vchPubKey = key.GetPubKey();
@ -567,7 +567,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
}
}
mapKeys.clear();
BOOST_FOREACH(SproutSpendingKeyMap::value_type& mSproutSpendingKey, mapSproutSpendingKeys)
for (SproutSpendingKeyMap::value_type& mSproutSpendingKey : mapSproutSpendingKeys)
{
const libzcash::SproutSpendingKey &sk = mSproutSpendingKey.second;
CSecureDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
@ -584,7 +584,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
}
mapSproutSpendingKeys.clear();
//! Sapling key support
BOOST_FOREACH(SaplingSpendingKeyMap::value_type& mSaplingSpendingKey, mapSaplingSpendingKeys)
for (SaplingSpendingKeyMap::value_type& mSaplingSpendingKey : mapSaplingSpendingKeys)
{
const auto &sk = mSaplingSpendingKey.second;
CSecureDataStream ss(SER_NETWORK, PROTOCOL_VERSION);

View File

@ -50,7 +50,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 {

View File

@ -121,12 +121,12 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
uint256 hash = wtx.GetHash();
entry.pushKV("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.pushKV("walletconflicts", conflicts);
entry.pushKV("time", wtx.GetTxTime());
entry.pushKV("timereceived", (int64_t)wtx.nTimeReceived);
BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)
for (const PAIRTYPE(string,string)& item : wtx.mapValue)
entry.pushKV(item.first, item.second);
entry.pushKV("vjoinsplit", TxJoinSplitToJSON(wtx));
@ -199,7 +199,7 @@ CTxDestination GetAccountAddress(std::string strAccount, bool bForceNew=false)
++it)
{
const CWalletTx& wtx = (*it).second;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
for (const CTxOut& txout : wtx.vout)
if (txout.scriptPubKey == scriptPubKey)
bKeyUsed = true;
}
@ -662,7 +662,7 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp)
if (wtx.IsCoinBase() || !CheckFinalTx(wtx))
continue;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
for (const CTxOut& txout : wtx.vout)
if (txout.scriptPubKey == scriptPubKey)
if (wtx.GetDepthInMainChain() >= nMinDepth)
nAmount += txout.nValue;
@ -722,7 +722,7 @@ UniValue getreceivedbyaccount(const UniValue& params, bool fHelp)
if (wtx.IsCoinBase() || !CheckFinalTx(wtx))
continue;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
for (const CTxOut& txout : wtx.vout)
{
CTxDestination address;
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwalletMain, address) && setAddress.count(address))
@ -828,10 +828,10 @@ UniValue getbalance(const UniValue& params, bool fHelp)
wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter);
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
BOOST_FOREACH(const COutputEntry& r, listReceived)
for (const COutputEntry& r : listReceived)
nBalance += r.amount;
}
BOOST_FOREACH(const COutputEntry& s, listSent)
for (const COutputEntry& s : listSent)
nBalance -= s.amount;
nBalance -= allFee;
}
@ -1220,7 +1220,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
if (nDepth < nMinDepth)
continue;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
for (const CTxOut& txout : wtx.vout)
{
CTxDestination address;
if (!ExtractDestination(txout.scriptPubKey, address))
@ -1281,7 +1281,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
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());
}
@ -1409,7 +1409,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
// Sent
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
{
BOOST_FOREACH(const COutputEntry& s, listSent)
for (const COutputEntry& s : listSent)
{
UniValue entry(UniValue::VOBJ);
if(involvesWatchonly || (::IsMine(*pwalletMain, s.destination) & ISMINE_WATCH_ONLY))
@ -1431,7 +1431,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
// Received
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
{
BOOST_FOREACH(const COutputEntry& r, listReceived)
for (const COutputEntry& r : listReceived)
{
string account;
if (pwalletMain->mapAddressBook.count(r.destination))
@ -1650,7 +1650,7 @@ UniValue listaccounts(const UniValue& params, bool fHelp)
includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY;
map<string, CAmount> mapAccountBalances;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& entry, pwalletMain->mapAddressBook) {
for (const PAIRTYPE(CTxDestination, CAddressBookData)& entry : pwalletMain->mapAddressBook) {
if (IsMine(*pwalletMain, entry.first) & includeWatchonly) // This address belongs to me
mapAccountBalances[entry.second.name] = 0;
}
@ -1667,11 +1667,11 @@ UniValue listaccounts(const UniValue& params, bool fHelp)
continue;
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly);
mapAccountBalances[strSentAccount] -= nFee;
BOOST_FOREACH(const COutputEntry& s, listSent)
for (const COutputEntry& s : listSent)
mapAccountBalances[strSentAccount] -= s.amount;
if (nDepth >= nMinDepth)
{
BOOST_FOREACH(const COutputEntry& r, listReceived)
for (const COutputEntry& r : listReceived)
if (pwalletMain->mapAddressBook.count(r.destination))
mapAccountBalances[pwalletMain->mapAddressBook[r.destination].name] += r.amount;
else
@ -1681,11 +1681,11 @@ UniValue listaccounts(const UniValue& params, bool fHelp)
list<CAccountingEntry> acentries;
CWalletDB(pwalletMain->strWalletFile).ListAccountCreditDebit("*", acentries);
BOOST_FOREACH(const CAccountingEntry& entry, acentries)
for (const CAccountingEntry& entry : acentries)
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
UniValue ret(UniValue::VOBJ);
BOOST_FOREACH(const PAIRTYPE(string, CAmount)& accountBalance, mapAccountBalances) {
for (const PAIRTYPE(string, CAmount)& accountBalance : mapAccountBalances) {
ret.pushKV(accountBalance.first, ValueFromAmount(accountBalance.second));
}
return ret;
@ -2300,7 +2300,7 @@ UniValue listlockunspent(const UniValue& params, bool fHelp)
UniValue ret(UniValue::VARR);
BOOST_FOREACH(COutPoint &outpt, vOutpts) {
for (COutPoint &outpt : vOutpts) {
UniValue o(UniValue::VOBJ);
o.pushKV("txid", outpt.hash.GetHex());
@ -2408,7 +2408,7 @@ UniValue resendwallettransactions(const UniValue& params, bool fHelp)
std::vector<uint256> txids = pwalletMain->ResendWalletTransactionsBefore(GetTime());
UniValue result(UniValue::VARR);
BOOST_FOREACH(const uint256& txid, txids)
for (const uint256& txid : txids)
{
result.push_back(txid.ToString());
}
@ -2491,7 +2491,7 @@ UniValue listunspent(const UniValue& params, bool fHelp)
assert(pwalletMain != NULL);
LOCK2(cs_main, pwalletMain->cs_wallet);
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
BOOST_FOREACH(const COutput& out, vecOutputs) {
for (const COutput& out : vecOutputs) {
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
continue;
@ -3360,7 +3360,7 @@ CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ign
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
BOOST_FOREACH(const COutput& out, vecOutputs) {
for (const COutput& out : vecOutputs) {
if (out.nDepth < minDepth) {
continue;
}
@ -4577,7 +4577,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, true);
// Find unspent coinbase utxos and update estimated size
BOOST_FOREACH(const COutput& out, vecOutputs) {
for (const COutput& out : vecOutputs) {
if (!out.fSpendable) {
continue;
}

View File

@ -24,7 +24,7 @@ GetResults(CWalletDB& walletdb, std::map<CAmount, CAccountingEntry>& results)
results.clear();
BOOST_CHECK(walletdb.ReorderTransactions(pwalletMain) == DB_LOAD_OK);
walletdb.ListAccountCreditDebit("", aes);
BOOST_FOREACH(CAccountingEntry& ae, aes)
for (CAccountingEntry& ae : aes)
{
results[ae.nOrderPos] = ae;
}

View File

@ -54,7 +54,7 @@ static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = fa
static void empty_wallet(void)
{
BOOST_FOREACH(COutput output, vCoins)
for (COutput output : vCoins)
delete output.tx;
vCoins.clear();
}

View File

@ -516,7 +516,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase)
{
LOCK(cs_wallet);
BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys)
for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
{
if(!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
return false;
@ -545,7 +545,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
CCrypter crypter;
CKeyingMaterial vMasterKey;
BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys)
for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
{
if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
return false;
@ -817,7 +817,7 @@ set<uint256> CWallet::GetConflicts(const uint256& txid) const
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range;
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
for (const CTxIn& txin : wtx.vin)
{
if (mapTxSpends.count(txin.prevout) <= 1)
continue; // No conflict if zero or one spends
@ -1432,7 +1432,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries,
}
acentries.clear();
walletdb.ListAccountCreditDebit(strAccount, acentries);
BOOST_FOREACH(CAccountingEntry& entry, acentries)
for (CAccountingEntry& entry : acentries)
{
txOrdered.insert(make_pair(entry.nOrderPos, TxPair((CWalletTx*)0, &entry)));
}
@ -1444,7 +1444,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();
}
}
@ -1801,7 +1801,7 @@ void CWallet::MarkAffectedTransactionsDirty(const CTransaction& tx)
// 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();
@ -2114,7 +2114,7 @@ CAmount CWallet::GetChange(const CTxOut& txout) const
bool CWallet::IsMine(const CTransaction& tx) const
{
BOOST_FOREACH(const CTxOut& txout, tx.vout)
for (const CTxOut& txout : tx.vout)
if (IsMine(txout))
return true;
return false;
@ -2143,7 +2143,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))
@ -2155,7 +2155,7 @@ CAmount CWallet::GetDebit(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))
@ -2167,7 +2167,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))
@ -2651,13 +2651,13 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived,
if (strAccount == strSentAccount)
{
BOOST_FOREACH(const COutputEntry& s, listSent)
for (const COutputEntry& s : listSent)
nSent += s.amount;
nFee = allFee;
}
{
LOCK(pwallet->cs_wallet);
BOOST_FOREACH(const COutputEntry& r, listReceived)
for (const COutputEntry& r : listReceived)
{
if (pwallet->mapAddressBook.count(r.destination))
{
@ -2692,22 +2692,22 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
CBlock block;
ReadBlockFromDisk(block, pindex, Params().GetConsensus());
BOOST_FOREACH(const CTransaction& tx, block.vtx)
for (const CTransaction& tx : block.vtx)
{
BOOST_FOREACH(const JSDescription& jsdesc, tx.vJoinSplit)
for (const JSDescription& jsdesc : tx.vJoinSplit)
{
BOOST_FOREACH(const uint256 &note_commitment, jsdesc.commitments)
for (const uint256 &note_commitment : jsdesc.commitments)
{
tree.append(note_commitment);
BOOST_FOREACH(boost::optional<SproutWitness>& wit, witnesses) {
for (boost::optional<SproutWitness>& wit : witnesses) {
if (wit) {
wit->append(note_commitment);
}
}
size_t i = 0;
BOOST_FOREACH(uint256& commitment, commitments) {
for (uint256& commitment : commitments) {
if (note_commitment == commitment) {
witnesses.at(i) = tree.witness();
}
@ -2730,7 +2730,7 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
// TODO: #93; Select a root via some heuristic.
final_anchor = tree.root();
BOOST_FOREACH(boost::optional<SproutWitness>& wit, witnesses) {
for (boost::optional<SproutWitness>& wit : witnesses) {
if (wit) {
assert(final_anchor == wit->root());
}
@ -2771,7 +2771,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
CBlock block;
ReadBlockFromDisk(block, pindex, Params().GetConsensus());
BOOST_FOREACH(CTransaction& tx, block.vtx)
for (CTransaction& tx : block.vtx)
{
if (AddToWalletIfInvolvingMe(tx, &block, pindex->nHeight, fUpdate)) {
myTxHashes.push_back(tx.GetHash());
@ -2825,7 +2825,7 @@ void CWallet::ReacceptWalletTransactions()
std::map<int64_t, CWalletTx*> 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;
@ -2839,7 +2839,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);
@ -3048,7 +3048,7 @@ bool CWalletTx::IsTrusted() const
return false;
// Trusted if all inputs are from us and are in the mempool:
BOOST_FOREACH(const CTxIn& txin, vin)
for (const CTxIn& txin : vin)
{
// Transactions not sent by us: not trusted
const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash);
@ -3068,7 +3068,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
LOCK(cs_wallet);
// Sort them in chronological order
multimap<unsigned int, CWalletTx*> 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:
@ -3076,7 +3076,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
continue;
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
}
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
for (PAIRTYPE(const unsigned int, CWalletTx*)& item : mapSorted)
{
CWalletTx& wtx = *item.second;
if (wtx.RelayWalletTransaction())
@ -3333,7 +3333,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
std::shuffle(vCoins.begin(), vCoins.end(), ZcashRandomEngine());
BOOST_FOREACH(const COutput &output, vCoins)
for (const COutput &output : vCoins)
{
if (!output.fSpendable)
continue;
@ -3455,7 +3455,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*
// 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;
@ -3472,7 +3472,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*
std::vector<COutPoint> vPresetInputs;
if (coinControl)
coinControl->ListSelected(vPresetInputs);
BOOST_FOREACH(const COutPoint& outpoint, vPresetInputs)
for (const COutPoint& outpoint : vPresetInputs)
{
map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash);
if (it != mapWallet.end())
@ -3515,7 +3515,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
vector<CRecipient> vecSend;
// Turn the txout set into a CRecipient vector
BOOST_FOREACH(const CTxOut& txOut, tx.vout)
for (const CTxOut& txOut : tx.vout)
{
CRecipient recipient = {txOut.scriptPubKey, txOut.nValue, false};
vecSend.push_back(recipient);
@ -3524,7 +3524,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
CCoinControl coinControl;
coinControl.fAllowOtherInputs = true;
coinControl.fAllowWatchOnly = includeWatching;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
for (const CTxIn& txin : tx.vin)
coinControl.Select(txin.prevout);
CReserveKey reservekey(this);
@ -3537,10 +3537,10 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
tx.vout.insert(tx.vout.begin() + nChangePosRet, wtx.vout[nChangePosRet]);
// Add new txins (keeping original txin scriptSig/order)
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
for (const CTxIn& txin : wtx.vin)
{
bool found = false;
BOOST_FOREACH(const CTxIn& origTxIn, tx.vin)
for (const CTxIn& origTxIn : tx.vin)
{
if (txin.prevout.hash == origTxIn.prevout.hash && txin.prevout.n == origTxIn.prevout.n)
{
@ -3560,7 +3560,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
{
CAmount nValue = 0;
unsigned int nSubtractFeeFromAmount = 0;
BOOST_FOREACH (const CRecipient& recipient, vecSend)
for (const CRecipient& recipient : vecSend)
{
if (nValue < 0 || recipient.nAmount < 0)
{
@ -3639,7 +3639,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
nTotalValue += nFeeRet;
double dPriority = 0;
// vouts to the payees
BOOST_FOREACH (const CRecipient& recipient, vecSend)
for (const CRecipient& recipient : vecSend)
{
CTxOut txout(recipient.nAmount, recipient.scriptPubKey);
@ -3686,7 +3686,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
}
return false;
}
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
for (PAIRTYPE(const CWalletTx*, unsigned int) pcoin : setCoins)
{
CAmount nCredit = pcoin.first->vout[pcoin.second].nValue;
//The coin age after the next block (depth+1) is used instead of the current,
@ -3779,7 +3779,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
//
// Note how the sequence number is set to max()-1 so that the
// nLockTime set above actually works.
BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
for (const PAIRTYPE(const CWalletTx*,unsigned int)& coin : setCoins)
txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(),
std::numeric_limits<unsigned int>::max()-1));
@ -3789,7 +3789,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
// Sign
int nIn = 0;
CTransaction txNewConst(txNew);
BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
for (const PAIRTYPE(const CWalletTx*,unsigned int)& coin : setCoins)
{
bool signSuccess;
const CScript& scriptPubKey = coin.first->vout[coin.second].scriptPubKey;
@ -3814,7 +3814,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
// Remove scriptSigs if we used dummy signatures for fee calculation
if (!sign) {
BOOST_FOREACH (CTxIn& vin, txNew.vin)
for (CTxIn& vin : txNew.vin)
vin.scriptSig = CScript();
}
@ -3892,7 +3892,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, boost::optional<CReserveKey&>
// Notify that old coins are spent
set<CWalletTx*> setCoins;
BOOST_FOREACH(const CTxIn& txin, wtxNew.vin)
for (const CTxIn& txin : wtxNew.vin)
{
CWalletTx &coin = mapWallet[txin.prevout.hash];
coin.BindWallet(this);
@ -4035,7 +4035,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
{
// Delete destdata tuples associated with address
std::string strAddress = keyIO.EncodeDestination(address);
BOOST_FOREACH(const PAIRTYPE(string, string) &item, mapAddressBook[address].destdata)
for (const PAIRTYPE(string, string) &item : mapAddressBook[address].destdata)
{
CWalletDB(strWalletFile).EraseDestData(strAddress, item.first);
}
@ -4071,7 +4071,7 @@ bool CWallet::NewKeyPool()
{
LOCK(cs_wallet);
CWalletDB walletdb(strWalletFile);
BOOST_FOREACH(int64_t nIndex, setKeyPool)
for (int64_t nIndex : setKeyPool)
walletdb.ErasePool(nIndex);
setKeyPool.clear();
@ -4205,7 +4205,7 @@ std::map<CTxDestination, CAmount> CWallet::GetAddressBalances()
{
LOCK(cs_wallet);
BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet)
for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet)
{
CWalletTx *pcoin = &walletEntry.second;
@ -4245,7 +4245,7 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
set< set<CTxDestination> > groupings;
set<CTxDestination> grouping;
BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet)
for (PAIRTYPE(uint256, CWalletTx) walletEntry : mapWallet)
{
CWalletTx *pcoin = &walletEntry.second;
@ -4253,7 +4253,7 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
{
bool any_mine = false;
// group all input addresses with each other
BOOST_FOREACH(CTxIn txin, pcoin->vin)
for (CTxIn txin : pcoin->vin)
{
CTxDestination address;
if(!IsMine(txin)) /* If this input isn't mine, ignore it */
@ -4267,7 +4267,7 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
// group change with input addresses
if (any_mine)
{
BOOST_FOREACH(CTxOut txout, pcoin->vout)
for (CTxOut txout : pcoin->vout)
if (IsChange(txout))
{
CTxDestination txoutAddr;
@ -4298,18 +4298,18 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
set< set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses
map< CTxDestination, set<CTxDestination>* > setmap; // map addresses to the unique group containing it
BOOST_FOREACH(set<CTxDestination> grouping, groupings)
for (set<CTxDestination> grouping : groupings)
{
// make a set of all the groups hit by this new group
set< set<CTxDestination>* > hits;
map< CTxDestination, set<CTxDestination>* >::iterator it;
BOOST_FOREACH(CTxDestination address, grouping)
for (CTxDestination address : grouping)
if ((it = setmap.find(address)) != setmap.end())
hits.insert((*it).second);
// merge all hit groups into a new single group and delete old groups
set<CTxDestination>* merged = new set<CTxDestination>(grouping);
BOOST_FOREACH(set<CTxDestination>* hit, hits)
for (set<CTxDestination>* hit : hits)
{
merged->insert(hit->begin(), hit->end());
uniqueGroupings.erase(hit);
@ -4318,12 +4318,12 @@ set< set<CTxDestination> > CWallet::GetAddressGroupings()
uniqueGroupings.insert(merged);
// update setmap
BOOST_FOREACH(CTxDestination element, *merged)
for (CTxDestination element : *merged)
setmap[element] = merged;
}
set< set<CTxDestination> > ret;
BOOST_FOREACH(set<CTxDestination>* uniqueGrouping, uniqueGroupings)
for (set<CTxDestination>* uniqueGrouping : uniqueGroupings)
{
ret.insert(*uniqueGrouping);
delete uniqueGrouping;
@ -4336,7 +4336,7 @@ std::set<CTxDestination> CWallet::GetAccountAddresses(const std::string& strAcco
{
LOCK(cs_wallet);
set<CTxDestination> result;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, mapAddressBook)
for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : mapAddressBook)
{
const CTxDestination& address = item.first;
const string& strName = item.second.name;
@ -4386,7 +4386,7 @@ void CWallet::GetAllReserveKeys(set<CKeyID>& setAddress) const
CWalletDB walletdb(strWalletFile);
LOCK2(cs_main, cs_wallet);
BOOST_FOREACH(const int64_t& id, setKeyPool)
for (const int64_t& id : setKeyPool)
{
CKeyPool keypool;
if (!walletdb.ReadPool(id, keypool))
@ -4542,7 +4542,7 @@ public:
std::vector<CTxDestination> 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);
}
}
@ -4576,7 +4576,7 @@ void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const {
std::map<CKeyID, CBlockIndex*> mapKeyFirstBlock;
std::set<CKeyID> setKeys;
GetKeys(setKeys);
BOOST_FOREACH(const CKeyID &keyid, setKeys) {
for (const CKeyID &keyid : setKeys) {
if (mapKeyBirth.count(keyid) == 0)
mapKeyFirstBlock[keyid] = pindexMax;
}
@ -4595,10 +4595,10 @@ void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const {
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) {
// ... which are already in a block
int nHeight = blit->second->nHeight;
BOOST_FOREACH(const CTxOut &txout, wtx.vout) {
for (const CTxOut &txout : wtx.vout) {
// iterate over all their outputs
CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey);
BOOST_FOREACH(const CKeyID &keyid, vAffected) {
for (const CKeyID &keyid : vAffected) {
// ... and all their affected keys
std::map<CKeyID, CBlockIndex*>::iterator rit = mapKeyFirstBlock.find(keyid);
if (rit != mapKeyFirstBlock.end() && nHeight < rit->second->nHeight)
@ -4827,7 +4827,7 @@ bool CWallet::InitLoadWallet(bool clearWitnessCaches)
{
CWalletDB walletdb(walletFile);
BOOST_FOREACH(const CWalletTx& wtxOld, vWtx)
for (const CWalletTx& wtxOld : vWtx)
{
uint256 hash = wtxOld.GetHash();
std::map<uint256, CWalletTx>::iterator mi = walletInstance->mapWallet.find(hash);

View File

@ -307,7 +307,7 @@ CAmount CWalletDB::GetAccountCreditDebit(const string& strAccount)
ListAccountCreditDebit(strAccount, entries);
CAmount nCreditDebit = 0;
BOOST_FOREACH (const CAccountingEntry& entry, entries)
for (const CAccountingEntry& entry : entries)
nCreditDebit += entry.nCreditDebit;
return nCreditDebit;
@ -374,7 +374,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet)
}
list<CAccountingEntry> acentries;
ListAccountCreditDebit("", acentries);
BOOST_FOREACH(CAccountingEntry& entry, acentries)
for (CAccountingEntry& entry : acentries)
{
txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));
}
@ -405,7 +405,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet)
else
{
int64_t nOrderPosOff = 0;
BOOST_FOREACH(const int64_t& nOffsetStart, nOrderPosOffsets)
for (const int64_t& nOffsetStart : nOrderPosOffsets)
{
if (nOrderPos >= nOffsetStart)
++nOrderPosOff;
@ -986,7 +986,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
if ((wss.nKeys + wss.nCKeys) != wss.nKeyMeta)
pwallet->nTimeFirstKey = 1; // 0 would be considered 'no value'
BOOST_FOREACH(uint256 hash, wss.vWalletUpgrade)
for (uint256 hash : wss.vWalletUpgrade)
WriteTx(hash, pwallet->mapWallet[hash]);
// Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
@ -1086,7 +1086,7 @@ DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet, vector<CWalletTx>& vWtx)
return err;
// erase each wallet TX
BOOST_FOREACH (uint256& hash, vTxHash) {
for (uint256& hash : vTxHash) {
if (!EraseTx(hash))
return DB_CORRUPT;
}
@ -1242,7 +1242,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, const std::string& filename, bool fOnlyKe
CWalletScanState wss;
DbTxn* ptxn = dbenv.TxnBegin();
BOOST_FOREACH(CDBEnv::KeyValPair& row, salvagedData)
for (CDBEnv::KeyValPair& row : salvagedData)
{
if (fOnlyKeys)
{

View File

@ -966,7 +966,7 @@ bool IncrementalMerkleTree<Depth, Hash>::is_complete(size_t depth) const {
return false;
}
BOOST_FOREACH(const boost::optional<Hash>& parent, parents) {
for (const boost::optional<Hash>& parent : parents) {
if (!parent) {
return false;
}
@ -997,7 +997,7 @@ size_t IncrementalMerkleTree<Depth, Hash>::next_depth(size_t skip) const {
size_t d = 1;
BOOST_FOREACH(const boost::optional<Hash>& parent, parents) {
for (const boost::optional<Hash>& parent : parents) {
if (!parent) {
if (skip) {
skip--;
@ -1025,7 +1025,7 @@ Hash IncrementalMerkleTree<Depth, Hash>::root(size_t depth,
size_t d = 1;
BOOST_FOREACH(const boost::optional<Hash>& parent, parents) {
for (const boost::optional<Hash>& parent : parents) {
if (parent) {
root = Hash::combine(*parent, root, d);
} else {
@ -1068,7 +1068,7 @@ MerklePath IncrementalMerkleTree<Depth, Hash>::path(std::deque<Hash> filler_hash
size_t d = 1;
BOOST_FOREACH(const boost::optional<Hash>& parent, parents) {
for (const boost::optional<Hash>& parent : parents) {
if (parent) {
index.push_back(true);
path.push_back(*parent);
@ -1087,7 +1087,7 @@ MerklePath IncrementalMerkleTree<Depth, Hash>::path(std::deque<Hash> filler_hash
}
std::vector<std::vector<bool>> merkle_path;
BOOST_FOREACH(Hash b, path)
for (Hash b : path)
{
std::vector<unsigned char> hashv(b.begin(), b.end());