Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations.
This commit is contained in:
parent
f180e81d57
commit
f34c8c466a
36 changed files with 77 additions and 77 deletions
|
@ -62,7 +62,7 @@ uint32_t PolyMod(const data& v)
|
|||
// v, it corresponds to x^2 + v0*x + v1 mod g(x). As 1 mod g(x) = 1, that is the starting value
|
||||
// for `c`.
|
||||
uint32_t c = 1;
|
||||
for (auto v_i : v) {
|
||||
for (const auto v_i : v) {
|
||||
// We want to update `c` to correspond to a polynomial with one extra term. If the initial
|
||||
// value of `c` consists of the coefficients of c(x) = f(x) mod g(x), we modify it to
|
||||
// correspond to c'(x) = (f(x) * x + v_i) mod g(x), where v_i is the next input to
|
||||
|
@ -149,7 +149,7 @@ std::string Encode(const std::string& hrp, const data& values) {
|
|||
data combined = Cat(values, checksum);
|
||||
std::string ret = hrp + '1';
|
||||
ret.reserve(ret.size() + combined.size());
|
||||
for (auto c : combined) {
|
||||
for (const auto c : combined) {
|
||||
ret += CHARSET[c];
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -385,7 +385,7 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s
|
|||
CScript scriptPubKey = GetScriptForMultisig(required, pubkeys);
|
||||
|
||||
if (bSegWit) {
|
||||
for (CPubKey& pubkey : pubkeys) {
|
||||
for (const CPubKey& pubkey : pubkeys) {
|
||||
if (!pubkey.IsCompressed()) {
|
||||
throw std::runtime_error("Uncompressed pubkeys are not useable for SegWit outputs");
|
||||
}
|
||||
|
|
|
@ -397,7 +397,7 @@ public:
|
|||
std::array<uint32_t, 8> locs = compute_hashes(e);
|
||||
// Make sure we have not already inserted this element
|
||||
// If we have, make sure that it does not get deleted
|
||||
for (uint32_t loc : locs)
|
||||
for (const uint32_t loc : locs)
|
||||
if (table[loc] == e) {
|
||||
please_keep(loc);
|
||||
epoch_flags[loc] = last_epoch;
|
||||
|
@ -405,7 +405,7 @@ public:
|
|||
}
|
||||
for (uint8_t depth = 0; depth < depth_limit; ++depth) {
|
||||
// First try to insert to an empty slot, if one exists
|
||||
for (uint32_t loc : locs) {
|
||||
for (const uint32_t loc : locs) {
|
||||
if (!collection_flags.bit_is_set(loc))
|
||||
continue;
|
||||
table[loc] = std::move(e);
|
||||
|
@ -467,7 +467,7 @@ public:
|
|||
inline bool contains(const Element& e, const bool erase) const
|
||||
{
|
||||
std::array<uint32_t, 8> locs = compute_hashes(e);
|
||||
for (uint32_t loc : locs)
|
||||
for (const uint32_t loc : locs)
|
||||
if (table[loc] == e) {
|
||||
if (erase)
|
||||
allow_erase(loc);
|
||||
|
|
|
@ -344,7 +344,7 @@ CNode* CConnman::FindNode(const CService& addr)
|
|||
bool CConnman::CheckIncomingNonce(uint64_t nonce)
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
for (CNode* pnode : vNodes) {
|
||||
for (const CNode* pnode : vNodes) {
|
||||
if (!pnode->fSuccessfullyConnected && !pnode->fInbound && pnode->GetLocalNonce() == nonce)
|
||||
return false;
|
||||
}
|
||||
|
@ -1614,7 +1614,7 @@ void CConnman::ThreadDNSAddressSeed()
|
|||
|
||||
LOCK(cs_vNodes);
|
||||
int nRelevant = 0;
|
||||
for (auto pnode : vNodes) {
|
||||
for (const CNode* pnode : vNodes) {
|
||||
nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->fOneShot && !pnode->m_manual_connection && !pnode->fInbound;
|
||||
}
|
||||
if (nRelevant >= 2) {
|
||||
|
@ -1733,7 +1733,7 @@ int CConnman::GetExtraOutboundCount()
|
|||
int nOutbound = 0;
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
for (CNode* pnode : vNodes) {
|
||||
for (const CNode* pnode : vNodes) {
|
||||
if (!pnode->fInbound && !pnode->m_manual_connection && !pnode->fFeeler && !pnode->fDisconnect && !pnode->fOneShot && pnode->fSuccessfullyConnected) {
|
||||
++nOutbound;
|
||||
}
|
||||
|
@ -1803,7 +1803,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
|||
std::set<std::vector<unsigned char> > setConnected;
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
for (CNode* pnode : vNodes) {
|
||||
for (const CNode* pnode : vNodes) {
|
||||
if (!pnode->fInbound && !pnode->m_manual_connection) {
|
||||
// Netgroups for inbound and addnode peers are not excluded because our goal here
|
||||
// is to not use multiple of our limited outbound slots on a single netgroup
|
||||
|
|
|
@ -882,7 +882,7 @@ void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pb
|
|||
// Erase orphan transactions included or precluded by this block
|
||||
if (vOrphanErase.size()) {
|
||||
int nErased = 0;
|
||||
for (uint256 &orphanHash : vOrphanErase) {
|
||||
for (const uint256& orphanHash : vOrphanErase) {
|
||||
nErased += EraseOrphanTx(orphanHash);
|
||||
}
|
||||
LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased);
|
||||
|
@ -2288,7 +2288,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||
}
|
||||
}
|
||||
|
||||
for (uint256 hash : vEraseQueue)
|
||||
for (const uint256& hash : vEraseQueue)
|
||||
EraseOrphanTx(hash);
|
||||
}
|
||||
else if (fMissingInputs)
|
||||
|
|
|
@ -416,7 +416,7 @@ void BitcoinApplication::requestShutdown()
|
|||
|
||||
#ifdef ENABLE_WALLET
|
||||
window->removeAllWallets();
|
||||
for (WalletModel *walletModel : m_wallet_models) {
|
||||
for (const WalletModel* walletModel : m_wallet_models) {
|
||||
delete walletModel;
|
||||
}
|
||||
m_wallet_models.clear();
|
||||
|
|
|
@ -1273,7 +1273,7 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
|
|||
void UnitDisplayStatusBarControl::createContextMenu()
|
||||
{
|
||||
menu = new QMenu(this);
|
||||
for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
|
||||
for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
|
||||
{
|
||||
QAction *menuAction = new QAction(QString(BitcoinUnits::longName(u)), this);
|
||||
menuAction->setData(QVariant(u));
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
interfaces::Node::NodesStats nodes_stats;
|
||||
node.getNodesStats(nodes_stats);
|
||||
cachedNodeStats.reserve(nodes_stats.size());
|
||||
for (auto& node_stats : nodes_stats)
|
||||
for (const auto& node_stats : nodes_stats)
|
||||
{
|
||||
CNodeCombinedStats stats;
|
||||
stats.nodeStats = std::get<0>(node_stats);
|
||||
|
|
|
@ -348,7 +348,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
|||
questionString.append("<hr />");
|
||||
CAmount totalAmount = currentTransaction.getTotalTransactionAmount() + txFee;
|
||||
QStringList alternativeUnits;
|
||||
for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
|
||||
for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
|
||||
{
|
||||
if(u != model->getOptionsModel()->getDisplayUnit())
|
||||
alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u, totalAmount));
|
||||
|
|
|
@ -200,7 +200,7 @@ void SplashScreen::unsubscribeFromCoreSignals()
|
|||
// Disconnect signals from client
|
||||
m_handler_init_message->disconnect();
|
||||
m_handler_show_progress->disconnect();
|
||||
for (auto& handler : m_connected_wallet_handlers) {
|
||||
for (const auto& handler : m_connected_wallet_handlers) {
|
||||
handler->disconnect();
|
||||
}
|
||||
m_connected_wallet_handlers.clear();
|
||||
|
|
|
@ -141,10 +141,10 @@ void TrafficGraphWidget::updateRates()
|
|||
}
|
||||
|
||||
float tmax = 0.0f;
|
||||
for (float f : vSamplesIn) {
|
||||
for (const float f : vSamplesIn) {
|
||||
if(f > tmax) tmax = f;
|
||||
}
|
||||
for (float f : vSamplesOut) {
|
||||
for (const float f : vSamplesOut) {
|
||||
if(f > tmax) tmax = f;
|
||||
}
|
||||
fMax = tmax;
|
||||
|
|
|
@ -152,13 +152,13 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
|||
else
|
||||
{
|
||||
isminetype fAllFromMe = ISMINE_SPENDABLE;
|
||||
for (isminetype mine : wtx.txin_is_mine)
|
||||
for (const isminetype mine : wtx.txin_is_mine)
|
||||
{
|
||||
if(fAllFromMe > mine) fAllFromMe = mine;
|
||||
}
|
||||
|
||||
isminetype fAllToMe = ISMINE_SPENDABLE;
|
||||
for (isminetype mine : wtx.txout_is_mine)
|
||||
for (const isminetype mine : wtx.txout_is_mine)
|
||||
{
|
||||
if(fAllToMe > mine) fAllToMe = mine;
|
||||
}
|
||||
|
|
|
@ -77,14 +77,14 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
|
|||
{
|
||||
bool involvesWatchAddress = false;
|
||||
isminetype fAllFromMe = ISMINE_SPENDABLE;
|
||||
for (isminetype mine : wtx.txin_is_mine)
|
||||
for (const isminetype mine : wtx.txin_is_mine)
|
||||
{
|
||||
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
|
||||
if(fAllFromMe > mine) fAllFromMe = mine;
|
||||
}
|
||||
|
||||
isminetype fAllToMe = ISMINE_SPENDABLE;
|
||||
for (isminetype mine : wtx.txout_is_mine)
|
||||
for (const isminetype mine : wtx.txout_is_mine)
|
||||
{
|
||||
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
|
||||
if(fAllToMe > mine) fAllToMe = mine;
|
||||
|
|
|
@ -426,7 +426,7 @@ static void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCK
|
|||
UniValue spent(UniValue::VARR);
|
||||
const CTxMemPool::txiter &it = mempool.mapTx.find(tx.GetHash());
|
||||
const CTxMemPool::setEntries &setChildren = mempool.GetMemPoolChildren(it);
|
||||
for (const CTxMemPool::txiter &childiter : setChildren) {
|
||||
for (CTxMemPool::txiter childiter : setChildren) {
|
||||
spent.push_back(childiter->GetTx().GetHash().ToString());
|
||||
}
|
||||
|
||||
|
|
|
@ -922,7 +922,7 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
|
|||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
|
||||
for (FeeEstimateHorizon horizon : {FeeEstimateHorizon::SHORT_HALFLIFE, FeeEstimateHorizon::MED_HALFLIFE, FeeEstimateHorizon::LONG_HALFLIFE}) {
|
||||
for (const FeeEstimateHorizon horizon : {FeeEstimateHorizon::SHORT_HALFLIFE, FeeEstimateHorizon::MED_HALFLIFE, FeeEstimateHorizon::LONG_HALFLIFE}) {
|
||||
CFeeRate feeRate;
|
||||
EstimationResult buckets;
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
|||
obj.pushKV("synced_headers", statestats.nSyncHeight);
|
||||
obj.pushKV("synced_blocks", statestats.nCommonHeight);
|
||||
UniValue heights(UniValue::VARR);
|
||||
for (int height : statestats.vHeightInFlight) {
|
||||
for (const int height : statestats.vHeightInFlight) {
|
||||
heights.push_back(height);
|
||||
}
|
||||
obj.pushKV("inflight", heights);
|
||||
|
|
|
@ -155,7 +155,7 @@ static void Correct_Queue_range(std::vector<size_t> range)
|
|||
}
|
||||
// Make vChecks here to save on malloc (this test can be slow...)
|
||||
std::vector<FakeCheckCheckCompletion> vChecks;
|
||||
for (auto i : range) {
|
||||
for (const size_t i : range) {
|
||||
size_t total = i;
|
||||
FakeCheckCheckCompletion::n_calls = 0;
|
||||
CCheckQueueControl<FakeCheckCheckCompletion> control(small_queue.get());
|
||||
|
@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
|
|||
}
|
||||
|
||||
for (auto times = 0; times < 10; ++times) {
|
||||
for (bool end_fails : {true, false}) {
|
||||
for (const bool end_fails : {true, false}) {
|
||||
CCheckQueueControl<FailingCheck> control(fail_queue.get());
|
||||
{
|
||||
std::vector<FailingCheck> vChecks;
|
||||
|
|
|
@ -736,7 +736,7 @@ static void CheckAddCoinBase(CAmount base_value, CAmount cache_value, CAmount mo
|
|||
template <typename... Args>
|
||||
static void CheckAddCoin(Args&&... args)
|
||||
{
|
||||
for (CAmount base_value : {ABSENT, PRUNED, VALUE1})
|
||||
for (const CAmount base_value : {ABSENT, PRUNED, VALUE1})
|
||||
CheckAddCoinBase(base_value, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
@ -848,10 +848,10 @@ BOOST_AUTO_TEST_CASE(ccoins_write)
|
|||
// they would be too repetitive (the parent cache is never updated in these
|
||||
// cases). The loop below covers these cases and makes sure the parent cache
|
||||
// is always left unchanged.
|
||||
for (CAmount parent_value : {ABSENT, PRUNED, VALUE1})
|
||||
for (CAmount child_value : {ABSENT, PRUNED, VALUE2})
|
||||
for (char parent_flags : parent_value == ABSENT ? ABSENT_FLAGS : FLAGS)
|
||||
for (char child_flags : child_value == ABSENT ? ABSENT_FLAGS : CLEAN_FLAGS)
|
||||
for (const CAmount parent_value : {ABSENT, PRUNED, VALUE1})
|
||||
for (const CAmount child_value : {ABSENT, PRUNED, VALUE2})
|
||||
for (const char parent_flags : parent_value == ABSENT ? ABSENT_FLAGS : FLAGS)
|
||||
for (const char child_flags : child_value == ABSENT ? ABSENT_FLAGS : CLEAN_FLAGS)
|
||||
CheckWriteCoins(parent_value, child_value, parent_value, parent_flags, child_flags, parent_flags);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,11 +82,11 @@ static double test_cache(size_t megabytes, double load)
|
|||
*/
|
||||
std::vector<uint256> hashes_insert_copy = hashes;
|
||||
/** Do the insert */
|
||||
for (uint256& h : hashes_insert_copy)
|
||||
for (const uint256& h : hashes_insert_copy)
|
||||
set.insert(h);
|
||||
/** Count the hits */
|
||||
uint32_t count = 0;
|
||||
for (uint256& h : hashes)
|
||||
for (const uint256& h : hashes)
|
||||
count += set.contains(h, false);
|
||||
double hit_rate = ((double)count) / ((double)n_insert);
|
||||
return hit_rate;
|
||||
|
@ -323,7 +323,7 @@ static void test_cache_generations()
|
|||
reads.push_back(inserts[i]);
|
||||
for (uint32_t i = n_insert - (n_insert / 4); i < n_insert; ++i)
|
||||
reads.push_back(inserts[i]);
|
||||
for (auto h : inserts)
|
||||
for (const auto& h : inserts)
|
||||
c.insert(h);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ BOOST_FIXTURE_TEST_SUITE(dbwrapper_tests, BasicTestingSetup)
|
|||
BOOST_AUTO_TEST_CASE(dbwrapper)
|
||||
{
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (bool obfuscate : {false, true}) {
|
||||
for (const bool obfuscate : {false, true}) {
|
||||
fs::path ph = SetDataDir(std::string("dbwrapper").append(obfuscate ? "_true" : "_false"));
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
char key = 'k';
|
||||
|
@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper)
|
|||
BOOST_AUTO_TEST_CASE(dbwrapper_batch)
|
||||
{
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (bool obfuscate : {false, true}) {
|
||||
for (const bool obfuscate : {false, true}) {
|
||||
fs::path ph = SetDataDir(std::string("dbwrapper_batch").append(obfuscate ? "_true" : "_false"));
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
|
||||
|
@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_batch)
|
|||
BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
|
||||
{
|
||||
// Perform tests both obfuscated and non-obfuscated.
|
||||
for (bool obfuscate : {false, true}) {
|
||||
for (const bool obfuscate : {false, true}) {
|
||||
fs::path ph = SetDataDir(std::string("dbwrapper_iterator").append(obfuscate ? "_true" : "_false"));
|
||||
CDBWrapper dbw(ph, (1 << 20), true, false, obfuscate);
|
||||
|
||||
|
@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(iterator_ordering)
|
|||
if (x & 1) BOOST_CHECK(dbw.Write(key, value));
|
||||
}
|
||||
|
||||
for (int seek_start : {0x00, 0x80}) {
|
||||
for (const int seek_start : {0x00, 0x80}) {
|
||||
it->Seek((uint8_t)seek_start);
|
||||
for (unsigned int x=seek_start; x<255; ++x) {
|
||||
uint8_t key;
|
||||
|
@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE(iterator_string_ordering)
|
|||
}
|
||||
|
||||
std::unique_ptr<CDBIterator> it(const_cast<CDBWrapper&>(dbw).NewIterator());
|
||||
for (int seek_start : {0, 5}) {
|
||||
for (const int seek_start : {0, 5}) {
|
||||
snprintf(buf, sizeof(buf), "%d", seek_start);
|
||||
StringContentsSerializer seek_key(buf);
|
||||
it->Seek(seek_key);
|
||||
|
|
|
@ -24,7 +24,7 @@ static void ResetArgs(const std::string& strArg)
|
|||
|
||||
// Convert to char*:
|
||||
std::vector<const char*> vecChar;
|
||||
for (std::string& s : vecArg)
|
||||
for (const std::string& s : vecArg)
|
||||
vecChar.push_back(s.c_str());
|
||||
|
||||
std::string error;
|
||||
|
|
|
@ -136,7 +136,7 @@ BOOST_AUTO_TEST_CASE(key_io_invalid)
|
|||
std::string exp_base58string = test[0].get_str();
|
||||
|
||||
// must be invalid as public and as private key
|
||||
for (auto chain : { CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::REGTEST }) {
|
||||
for (const auto& chain : { CBaseChainParams::MAIN, CBaseChainParams::TESTNET, CBaseChainParams::REGTEST }) {
|
||||
SelectParams(chain);
|
||||
destination = DecodeDestination(exp_base58string);
|
||||
BOOST_CHECK_MESSAGE(!IsValidDestination(destination), "IsValid pubkey in mainnet:" + strTest);
|
||||
|
|
|
@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE(findearliestatleast_test)
|
|||
BOOST_AUTO_TEST_CASE(findearliestatleast_edge_test)
|
||||
{
|
||||
std::list<CBlockIndex> blocks;
|
||||
for (unsigned int timeMax : {100, 100, 100, 200, 200, 200, 300, 300, 300}) {
|
||||
for (const unsigned int timeMax : {100, 100, 100, 200, 200, 200, 300, 300, 300}) {
|
||||
CBlockIndex* prev = blocks.empty() ? nullptr : &blocks.back();
|
||||
blocks.emplace_back();
|
||||
blocks.back().nHeight = prev ? prev->nHeight + 1 : 0;
|
||||
|
|
|
@ -29,7 +29,7 @@ void CConnmanTest::AddNode(CNode& node)
|
|||
void CConnmanTest::ClearNodes()
|
||||
{
|
||||
LOCK(g_connman->cs_vNodes);
|
||||
for (CNode* node : g_connman->vNodes) {
|
||||
for (const CNode* node : g_connman->vNodes) {
|
||||
delete node;
|
||||
}
|
||||
g_connman->vNodes.clear();
|
||||
|
|
|
@ -65,7 +65,7 @@ unsigned int ParseScriptFlags(std::string strFlags)
|
|||
std::vector<std::string> words;
|
||||
boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(","));
|
||||
|
||||
for (std::string word : words)
|
||||
for (const std::string& word : words)
|
||||
{
|
||||
if (!mapFlagNames.count(word))
|
||||
BOOST_ERROR("Bad test: unknown verification flag '" << word << "'");
|
||||
|
|
|
@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(util_GetBoolArg)
|
|||
testArgs.ParseParameters(7, (char**)argv_test, error);
|
||||
|
||||
// Each letter should be set.
|
||||
for (char opt : "abcdef")
|
||||
for (const char opt : "abcdef")
|
||||
BOOST_CHECK(testArgs.IsArgSet({'-', opt}) || !opt);
|
||||
|
||||
// Nothing else should be in the map
|
||||
|
@ -394,7 +394,7 @@ BOOST_AUTO_TEST_CASE(util_ReadConfigStream)
|
|||
&& test_args.GetArg("-iii", "xxx") == "xxx"
|
||||
);
|
||||
|
||||
for (bool def : {false, true}) {
|
||||
for (const bool def : {false, true}) {
|
||||
BOOST_CHECK(test_args.GetBoolArg("-a", def)
|
||||
&& test_args.GetBoolArg("-b", def)
|
||||
&& !test_args.GetBoolArg("-ccc", def)
|
||||
|
|
|
@ -94,7 +94,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
|
|||
{
|
||||
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
|
||||
bool fMatch = false;
|
||||
for (int64_t nOffset : vSorted)
|
||||
for (const int64_t nOffset : vSorted)
|
||||
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
|
||||
fMatch = true;
|
||||
|
||||
|
@ -109,7 +109,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
|
|||
}
|
||||
|
||||
if (LogAcceptCategory(BCLog::NET)) {
|
||||
for (int64_t n : vSorted) {
|
||||
for (const int64_t n : vSorted) {
|
||||
LogPrint(BCLog::NET, "%+d ", n); /* Continued */
|
||||
}
|
||||
LogPrint(BCLog::NET, "| "); /* Continued */
|
||||
|
|
|
@ -196,7 +196,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntr
|
|||
}
|
||||
|
||||
const setEntries & setMemPoolParents = GetMemPoolParents(stageit);
|
||||
for (const txiter &phash : setMemPoolParents) {
|
||||
for (txiter phash : setMemPoolParents) {
|
||||
// If this is a new ancestor, add it.
|
||||
if (setAncestors.count(phash) == 0) {
|
||||
parentHashes.insert(phash);
|
||||
|
@ -457,7 +457,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries& setDescendants
|
|||
stage.erase(it);
|
||||
|
||||
const setEntries &setChildren = GetMemPoolChildren(it);
|
||||
for (const txiter &childiter : setChildren) {
|
||||
for (txiter childiter : setChildren) {
|
||||
if (!setDescendants.count(childiter)) {
|
||||
stage.insert(childiter);
|
||||
}
|
||||
|
@ -907,7 +907,7 @@ size_t CTxMemPool::DynamicMemoryUsage() const {
|
|||
void CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) {
|
||||
AssertLockHeld(cs);
|
||||
UpdateForRemoveFromMempool(stage, updateDescendants);
|
||||
for (const txiter& it : stage) {
|
||||
for (txiter it : stage) {
|
||||
removeUnchecked(it, reason);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ bool IsHexNumber(const std::string& str)
|
|||
if (str.size() > 2 && *str.begin() == '0' && *(str.begin()+1) == 'x') {
|
||||
starting_location = 2;
|
||||
}
|
||||
for (auto c : str.substr(starting_location)) {
|
||||
for (const char c : str.substr(starting_location)) {
|
||||
if (HexDigit(c) < 0) return false;
|
||||
}
|
||||
// Return false for empty string or "0x".
|
||||
|
|
|
@ -421,7 +421,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp, bool
|
|||
// lock on a mempool input, so we can use the return value of
|
||||
// CheckSequenceLocks to indicate the LockPoints validity
|
||||
int maxInputHeight = 0;
|
||||
for (int height : prevheights) {
|
||||
for (const int height : prevheights) {
|
||||
// Can ignore mempool inputs since we'll fail if they had non-zero locks
|
||||
if (height != tip->nHeight+1) {
|
||||
maxInputHeight = std::max(maxInputHeight, height);
|
||||
|
@ -4291,7 +4291,7 @@ void UnloadBlockIndex()
|
|||
warningcache[b].clear();
|
||||
}
|
||||
|
||||
for (BlockMap::value_type& entry : mapBlockIndex) {
|
||||
for (const BlockMap::value_type& entry : mapBlockIndex) {
|
||||
delete entry.second;
|
||||
}
|
||||
mapBlockIndex.clear();
|
||||
|
@ -4492,7 +4492,7 @@ void CChainState::CheckBlockIndex(const Consensus::Params& consensusParams)
|
|||
|
||||
// Build forward-pointing map of the entire block tree.
|
||||
std::multimap<CBlockIndex*,CBlockIndex*> forward;
|
||||
for (auto& entry : mapBlockIndex) {
|
||||
for (const std::pair<const uint256, CBlockIndex*>& entry : mapBlockIndex) {
|
||||
forward.insert(std::make_pair(entry.second->pprev, entry.second));
|
||||
}
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
|
|||
return false;
|
||||
|
||||
fUseCrypto = true;
|
||||
for (KeyMap::value_type& mKey : mapKeys)
|
||||
for (const KeyMap::value_type& mKey : mapKeys)
|
||||
{
|
||||
const CKey &key = mKey.second;
|
||||
CPubKey vchPubKey = key.GetPubKey();
|
||||
|
|
|
@ -503,7 +503,7 @@ BerkeleyBatch::BerkeleyBatch(BerkeleyDatabase& database, const char* pszMode, bo
|
|||
// be implemented, so no equality checks are needed at all. (Newer
|
||||
// versions of BDB have an set_lk_exclusive method for this
|
||||
// purpose, but the older version we use does not.)
|
||||
for (auto& env : g_dbenvs) {
|
||||
for (const auto& env : g_dbenvs) {
|
||||
CheckUniqueFileid(env.second, strFilename, *pdb_temp);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ int64_t static DecodeDumpTime(const std::string &str) {
|
|||
|
||||
std::string static EncodeDumpString(const std::string &str) {
|
||||
std::stringstream ret;
|
||||
for (unsigned char c : str) {
|
||||
for (const unsigned char c : str) {
|
||||
if (c <= 32 || c >= 128 || c == '%') {
|
||||
ret << '%' << HexStr(&c, &c + 1);
|
||||
} else {
|
||||
|
|
|
@ -2365,7 +2365,7 @@ static UniValue listlockunspent(const JSONRPCRequest& request)
|
|||
|
||||
UniValue ret(UniValue::VARR);
|
||||
|
||||
for (COutPoint &outpt : vOutpts) {
|
||||
for (const COutPoint& outpt : vOutpts) {
|
||||
UniValue o(UniValue::VOBJ);
|
||||
|
||||
o.pushKV("txid", outpt.hash.GetHex());
|
||||
|
|
|
@ -1579,7 +1579,7 @@ int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wall
|
|||
// Look up the inputs. We should have already checked that this transaction
|
||||
// IsAllFromMe(ISMINE_SPENDABLE), so every input should already be in our
|
||||
// wallet, with a valid index into the vout array, and the ability to sign.
|
||||
for (auto& input : tx.vin) {
|
||||
for (const CTxIn& input : tx.vin) {
|
||||
const auto mi = wallet->mapWallet.find(input.prevout.hash);
|
||||
if (mi == wallet->mapWallet.end()) {
|
||||
return -1;
|
||||
|
@ -1819,7 +1819,7 @@ void CWallet::ReacceptWalletTransactions()
|
|||
}
|
||||
|
||||
// Try to add wallet transactions to memory pool
|
||||
for (std::pair<const int64_t, CWalletTx*>& item : mapSorted) {
|
||||
for (const std::pair<const int64_t, CWalletTx*>& item : mapSorted) {
|
||||
CWalletTx& wtx = *(item.second);
|
||||
CValidationState state;
|
||||
wtx.AcceptToMemoryPool(maxTxFee, state);
|
||||
|
@ -2065,7 +2065,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon
|
|||
continue;
|
||||
mapSorted.insert(std::make_pair(wtx.nTimeReceived, &wtx));
|
||||
}
|
||||
for (std::pair<const unsigned int, CWalletTx*>& item : mapSorted)
|
||||
for (const std::pair<const unsigned int, CWalletTx*>& item : mapSorted)
|
||||
{
|
||||
CWalletTx& wtx = *item.second;
|
||||
if (wtx.RelayWalletTransaction(connman))
|
||||
|
@ -2368,7 +2368,7 @@ std::map<CTxDestination, std::vector<COutput>> CWallet::ListCoins() const
|
|||
LOCK2(cs_main, cs_wallet);
|
||||
AvailableCoins(availableCoins);
|
||||
|
||||
for (auto& coin : availableCoins) {
|
||||
for (const COutput& coin : availableCoins) {
|
||||
CTxDestination address;
|
||||
if (coin.fSpendable &&
|
||||
ExtractDestination(FindNonChangeParentOutput(*coin.tx->tx, coin.i).scriptPubKey, address)) {
|
||||
|
@ -2378,7 +2378,7 @@ std::map<CTxDestination, std::vector<COutput>> CWallet::ListCoins() const
|
|||
|
||||
std::vector<COutPoint> lockedCoins;
|
||||
ListLockedCoins(lockedCoins);
|
||||
for (const auto& output : lockedCoins) {
|
||||
for (const COutPoint& output : lockedCoins) {
|
||||
auto it = mapWallet.find(output.hash);
|
||||
if (it != mapWallet.end()) {
|
||||
int depth = it->second.GetDepthInMainChain();
|
||||
|
@ -3280,17 +3280,17 @@ bool CWallet::NewKeyPool()
|
|||
LOCK(cs_wallet);
|
||||
WalletBatch batch(*database);
|
||||
|
||||
for (int64_t nIndex : setInternalKeyPool) {
|
||||
for (const int64_t nIndex : setInternalKeyPool) {
|
||||
batch.ErasePool(nIndex);
|
||||
}
|
||||
setInternalKeyPool.clear();
|
||||
|
||||
for (int64_t nIndex : setExternalKeyPool) {
|
||||
for (const int64_t nIndex : setExternalKeyPool) {
|
||||
batch.ErasePool(nIndex);
|
||||
}
|
||||
setExternalKeyPool.clear();
|
||||
|
||||
for (int64_t nIndex : set_pre_split_keypool) {
|
||||
for (const int64_t nIndex : set_pre_split_keypool) {
|
||||
batch.ErasePool(nIndex);
|
||||
}
|
||||
set_pre_split_keypool.clear();
|
||||
|
@ -3567,7 +3567,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
|||
{
|
||||
bool any_mine = false;
|
||||
// group all input addresses with each other
|
||||
for (CTxIn txin : pcoin->tx->vin)
|
||||
for (const CTxIn& txin : pcoin->tx->vin)
|
||||
{
|
||||
CTxDestination address;
|
||||
if(!IsMine(txin)) /* If this input isn't mine, ignore it */
|
||||
|
@ -3581,7 +3581,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
|||
// group change with input addresses
|
||||
if (any_mine)
|
||||
{
|
||||
for (CTxOut txout : pcoin->tx->vout)
|
||||
for (const CTxOut& txout : pcoin->tx->vout)
|
||||
if (IsChange(txout))
|
||||
{
|
||||
CTxDestination txoutAddr;
|
||||
|
@ -3617,7 +3617,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
|||
// make a set of all the groups hit by this new group
|
||||
std::set< std::set<CTxDestination>* > hits;
|
||||
std::map< CTxDestination, std::set<CTxDestination>* >::iterator it;
|
||||
for (CTxDestination address : _grouping)
|
||||
for (const CTxDestination& address : _grouping)
|
||||
if ((it = setmap.find(address)) != setmap.end())
|
||||
hits.insert((*it).second);
|
||||
|
||||
|
@ -3632,12 +3632,12 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
|||
uniqueGroupings.insert(merged);
|
||||
|
||||
// update setmap
|
||||
for (CTxDestination element : *merged)
|
||||
for (const CTxDestination& element : *merged)
|
||||
setmap[element] = merged;
|
||||
}
|
||||
|
||||
std::set< std::set<CTxDestination> > ret;
|
||||
for (std::set<CTxDestination>* uniqueGrouping : uniqueGroupings)
|
||||
for (const std::set<CTxDestination>* uniqueGrouping : uniqueGroupings)
|
||||
{
|
||||
ret.insert(*uniqueGrouping);
|
||||
delete uniqueGrouping;
|
||||
|
|
|
@ -612,7 +612,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
|||
if ((wss.nKeys + wss.nCKeys + wss.nWatchKeys) != wss.nKeyMeta)
|
||||
pwallet->UpdateTimeFirstKey(1);
|
||||
|
||||
for (uint256 hash : wss.vWalletUpgrade)
|
||||
for (const uint256& hash : wss.vWalletUpgrade)
|
||||
WriteTx(pwallet->mapWallet.at(hash));
|
||||
|
||||
// Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
|
||||
|
@ -709,7 +709,7 @@ DBErrors WalletBatch::ZapSelectTx(std::vector<uint256>& vTxHashIn, std::vector<u
|
|||
// erase each matching wallet TX
|
||||
bool delerror = false;
|
||||
std::vector<uint256>::iterator it = vTxHashIn.begin();
|
||||
for (uint256 hash : vTxHash) {
|
||||
for (const uint256& hash : vTxHash) {
|
||||
while (it < vTxHashIn.end() && (*it) < hash) {
|
||||
it++;
|
||||
}
|
||||
|
@ -740,7 +740,7 @@ DBErrors WalletBatch::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
|||
return err;
|
||||
|
||||
// erase each wallet TX
|
||||
for (uint256& hash : vTxHash) {
|
||||
for (const uint256& hash : vTxHash) {
|
||||
if (!EraseTx(hash))
|
||||
return DBErrors::CORRUPT;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue