From f550a8e035b4603787273ea250f403f6f0be453f Mon Sep 17 00:00:00 2001 From: furszy Date: Thu, 15 Aug 2024 11:08:17 -0300 Subject: [PATCH] Rename ReleaseWallet to FlushAndDeleteWallet To better describe the function's behavior. And add wallet name to logprint. --- src/wallet/wallet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 09e12d52b91..057fa729d71 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -227,10 +227,10 @@ static std::set g_loading_wallet_set GUARDED_BY(g_loading_wallet_mu static std::set g_unloading_wallet_set GUARDED_BY(g_wallet_release_mutex); // Custom deleter for shared_ptr. -static void ReleaseWallet(CWallet* wallet) +static void FlushAndDeleteWallet(CWallet* wallet) { const std::string name = wallet->GetName(); - wallet->WalletLogPrintf("Releasing wallet\n"); + wallet->WalletLogPrintf("Releasing wallet %s..\n", name); wallet->Flush(); delete wallet; // Wallet is now released, notify WaitForDeleteWallet, if any. @@ -255,7 +255,7 @@ void WaitForDeleteWallet(std::shared_ptr&& wallet) // Multiple threads could simultaneously be waiting for deletion. } - // Time to ditch our shared_ptr and wait for ReleaseWallet call. + // Time to ditch our shared_ptr and wait for FlushAndDeleteWallet call. wallet.reset(); { WAIT_LOCK(g_wallet_release_mutex, lock); @@ -2972,7 +2972,7 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri const auto start{SteadyClock::now()}; // 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 walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet); + std::shared_ptr walletInstance(new CWallet(chain, name, std::move(database)), FlushAndDeleteWallet); walletInstance->m_keypool_size = std::max(args.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), int64_t{1}); walletInstance->m_notify_tx_changed_script = args.GetArg("-walletnotify", "");