mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-23 05:09:26 +02:00
refactor: const shared_ptrs
Introduce convention to use const shared pointers everywhere, unless the shared pointer is modified at some point, which it very rarely is. We want this convention, as it helps alleviate the misconception that a const shared pointer somehow results in a pointer to an immutable object, which is false.
This commit is contained in:
@@ -221,7 +221,7 @@ std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::s
|
||||
}
|
||||
|
||||
context.chain->initMessage(_("Loading wallet…").translated);
|
||||
std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), options.create_flags, error, warnings);
|
||||
const std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), options.create_flags, error, warnings);
|
||||
if (!wallet) {
|
||||
error = Untranslated("Wallet loading failed.") + Untranslated(" ") + error;
|
||||
status = DatabaseStatus::FAILED_LOAD;
|
||||
@@ -301,7 +301,7 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
|
||||
|
||||
// Make the wallet
|
||||
context.chain->initMessage(_("Loading wallet…").translated);
|
||||
std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), wallet_creation_flags, error, warnings);
|
||||
const std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), wallet_creation_flags, error, warnings);
|
||||
if (!wallet) {
|
||||
error = Untranslated("Wallet creation failed.") + Untranslated(" ") + error;
|
||||
status = DatabaseStatus::FAILED_CREATE;
|
||||
@@ -2540,7 +2540,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
||||
int64_t nStart = GetTimeMillis();
|
||||
// TODO: Can't use std::make_shared because we need a custom deleter but
|
||||
// should be possible to use std::allocate_shared.
|
||||
std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet);
|
||||
const std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet);
|
||||
bool rescan_required = false;
|
||||
DBErrors nLoadWalletRet = walletInstance->LoadWallet();
|
||||
if (nLoadWalletRet != DBErrors::LOAD_OK) {
|
||||
|
||||
Reference in New Issue
Block a user