mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 17:24:58 +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:
@@ -40,7 +40,7 @@ static void WalletCreate(CWallet* wallet_instance, uint64_t wallet_creation_flag
|
||||
wallet_instance->TopUpKeyPool();
|
||||
}
|
||||
|
||||
static std::shared_ptr<CWallet> MakeWallet(const std::string& name, const fs::path& path, DatabaseOptions options)
|
||||
static const std::shared_ptr<CWallet> MakeWallet(const std::string& name, const fs::path& path, DatabaseOptions options)
|
||||
{
|
||||
DatabaseStatus status;
|
||||
bilingual_str error;
|
||||
@@ -151,7 +151,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
||||
options.require_format = DatabaseFormat::SQLITE;
|
||||
}
|
||||
|
||||
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
|
||||
const std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
|
||||
if (wallet_instance) {
|
||||
WalletShowInfo(wallet_instance.get());
|
||||
wallet_instance->Close();
|
||||
@@ -159,7 +159,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
||||
} else if (command == "info") {
|
||||
DatabaseOptions options;
|
||||
options.require_existing = true;
|
||||
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
|
||||
const std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
|
||||
if (!wallet_instance) return false;
|
||||
WalletShowInfo(wallet_instance.get());
|
||||
wallet_instance->Close();
|
||||
@@ -184,7 +184,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
||||
} else if (command == "dump") {
|
||||
DatabaseOptions options;
|
||||
options.require_existing = true;
|
||||
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
|
||||
const std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
|
||||
if (!wallet_instance) return false;
|
||||
bilingual_str error;
|
||||
bool ret = DumpWallet(*wallet_instance, error);
|
||||
|
||||
Reference in New Issue
Block a user