diff options
author | Aurèle Oulès <aurele@oules.com> | 2022-07-26 11:12:53 +0200 |
---|---|---|
committer | Aurèle Oulès <aurele@oules.com> | 2022-07-27 13:27:57 +0200 |
commit | 081b0e53e3adca7ea57d23e5fcd9db4b86415a72 (patch) | |
tree | 877f1eb2d246084e645f8cf5961d5541438a308b /src/wallet | |
parent | 7f79746bf046d0028bb68f265804b9774dec2acb (diff) | |
download | bitcoin-081b0e53e3adca7ea57d23e5fcd9db4b86415a72.tar.xz |
refactor: Make const refs vars where applicable
This avoids initializing variables with the copy-constructor of a
non-trivially copyable type.
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/bdb.cpp | 2 | ||||
-rw-r--r-- | src/wallet/receive.cpp | 2 | ||||
-rw-r--r-- | src/wallet/rpc/spend.cpp | 2 | ||||
-rw-r--r-- | src/wallet/scriptpubkeyman.cpp | 2 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 2 | ||||
-rw-r--r-- | src/wallet/walletdb.cpp | 6 |
6 files changed, 8 insertions, 8 deletions
diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp index 60715ff3c8..deb1293cd4 100644 --- a/src/wallet/bdb.cpp +++ b/src/wallet/bdb.cpp @@ -432,7 +432,7 @@ void BerkeleyEnvironment::ReloadDbEnv() }); std::vector<fs::path> filenames; - for (auto it : m_databases) { + for (const auto& it : m_databases) { filenames.push_back(it.first); } // Close the individual Db's diff --git a/src/wallet/receive.cpp b/src/wallet/receive.cpp index 944925d600..916ec3fb1d 100644 --- a/src/wallet/receive.cpp +++ b/src/wallet/receive.cpp @@ -416,7 +416,7 @@ std::set< std::set<CTxDestination> > GetAddressGroupings(const CWallet& wallet) std::set< std::set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses std::map< CTxDestination, std::set<CTxDestination>* > setmap; // map addresses to the unique group containing it - for (std::set<CTxDestination> _grouping : groupings) + for (const std::set<CTxDestination>& _grouping : groupings) { // make a set of all the groups hit by this new group std::set< std::set<CTxDestination>* > hits; diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index b5472efa61..bd0f2f4824 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -1407,7 +1407,7 @@ RPCHelpMan sendall() } CAmount output_amounts_claimed{0}; - for (CTxOut out : rawTx.vout) { + for (const CTxOut& out : rawTx.vout) { output_amounts_claimed += out.nValue; } diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index bba31dfe0b..faed037ed7 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -1789,7 +1789,7 @@ std::map<CKeyID, CKey> DescriptorScriptPubKeyMan::GetKeys() const AssertLockHeld(cs_desc_man); if (m_storage.HasEncryptionKeys() && !m_storage.IsLocked()) { KeyMap keys; - for (auto key_pair : m_map_crypted_keys) { + for (const auto& key_pair : m_map_crypted_keys) { const CPubKey& pubkey = key_pair.second.first; const std::vector<unsigned char>& crypted_secret = key_pair.second.second; CKey key; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 54a3221e2d..d7dd41e8e7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3434,7 +3434,7 @@ void CWallet::SetupDescriptorScriptPubKeyMans() const UniValue& descriptor_vals = find_value(signer_res, internal ? "internal" : "receive"); if (!descriptor_vals.isArray()) throw std::runtime_error(std::string(__func__) + ": Unexpected result"); for (const UniValue& desc_val : descriptor_vals.get_array().getValues()) { - std::string desc_str = desc_val.getValStr(); + const std::string& desc_str = desc_val.getValStr(); FlatSigningProvider keys; std::string desc_error; std::unique_ptr<Descriptor> desc = Parse(desc_str, keys, desc_error, false); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 8afd3f416d..0d85652c0c 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -856,18 +856,18 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet) } // Set the descriptor caches - for (auto desc_cache_pair : wss.m_descriptor_caches) { + for (const auto& desc_cache_pair : wss.m_descriptor_caches) { auto spk_man = pwallet->GetScriptPubKeyMan(desc_cache_pair.first); assert(spk_man); ((DescriptorScriptPubKeyMan*)spk_man)->SetCache(desc_cache_pair.second); } // Set the descriptor keys - for (auto desc_key_pair : wss.m_descriptor_keys) { + for (const auto& desc_key_pair : wss.m_descriptor_keys) { auto spk_man = pwallet->GetScriptPubKeyMan(desc_key_pair.first.first); ((DescriptorScriptPubKeyMan*)spk_man)->AddKey(desc_key_pair.first.second, desc_key_pair.second); } - for (auto desc_key_pair : wss.m_descriptor_crypt_keys) { + for (const auto& desc_key_pair : wss.m_descriptor_crypt_keys) { auto spk_man = pwallet->GetScriptPubKeyMan(desc_key_pair.first.first); ((DescriptorScriptPubKeyMan*)spk_man)->AddCryptedKey(desc_key_pair.first.second, desc_key_pair.second.first, desc_key_pair.second.second); } |