mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 18:09:47 +01:00
Rename ReleaseWallet to FlushAndDeleteWallet
To better describe the function's behavior. And add wallet name to logprint.
This commit is contained in:
parent
64e736d79e
commit
f550a8e035
@ -227,10 +227,10 @@ static std::set<std::string> g_loading_wallet_set GUARDED_BY(g_loading_wallet_mu
|
||||
static std::set<std::string> g_unloading_wallet_set GUARDED_BY(g_wallet_release_mutex);
|
||||
|
||||
// Custom deleter for shared_ptr<CWallet>.
|
||||
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<CWallet>&& 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> 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<CWallet> walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet);
|
||||
std::shared_ptr<CWallet> 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", "");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user