Skip to content

Commit 8872b4a

Browse files
committed
wallet: rename UnloadWallet to WaitForDeleteWallet
And update function's documentation.
1 parent 5d15485 commit 8872b4a

File tree

7 files changed

+13
-16
lines changed

7 files changed

+13
-16
lines changed

src/bench/wallet_create.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
4242

4343
// Release wallet
4444
RemoveWallet(context, wallet, /*load_on_start=*/ std::nullopt);
45-
UnloadWallet(std::move(wallet));
45+
WaitForDeleteWallet(std::move(wallet));
4646
fs::remove_all(wallet_path);
4747
});
4848
}

src/wallet/load.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void UnloadWallets(WalletContext& context)
178178
wallets.pop_back();
179179
std::vector<bilingual_str> warnings;
180180
RemoveWallet(context, wallet, /* load_on_start= */ std::nullopt, warnings);
181-
UnloadWallet(std::move(wallet));
181+
WaitForDeleteWallet(std::move(wallet));
182182
}
183183
}
184184
} // namespace wallet

src/wallet/rpc/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static RPCHelpMan unloadwallet()
495495
}
496496
}
497497

498-
UnloadWallet(std::move(wallet));
498+
WaitForDeleteWallet(std::move(wallet));
499499

500500
UniValue result(UniValue::VOBJ);
501501
PushWarnings(warnings, result);

src/wallet/test/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void TestUnloadWallet(std::shared_ptr<CWallet>&& wallet)
7474
// Calls SyncWithValidationInterfaceQueue
7575
wallet->chain().waitForNotificationsIfTipChanged({});
7676
wallet->m_chain_notifications_handler.reset();
77-
UnloadWallet(std::move(wallet));
77+
WaitForDeleteWallet(std::move(wallet));
7878
}
7979

8080
std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database)

src/wallet/test/wallet_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWalletWithoutChain, BasicTestingSetup)
889889
context.args = &m_args;
890890
auto wallet = TestLoadWallet(context);
891891
BOOST_CHECK(wallet);
892-
UnloadWallet(std::move(wallet));
892+
WaitForDeleteWallet(std::move(wallet));
893893
}
894894

895895
BOOST_FIXTURE_TEST_CASE(RemoveTxs, TestChain100Setup)

src/wallet/wallet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,18 @@ static void ReleaseWallet(CWallet* wallet)
233233
wallet->WalletLogPrintf("Releasing wallet\n");
234234
wallet->Flush();
235235
delete wallet;
236-
// Wallet is now released, notify UnloadWallet, if any.
236+
// Wallet is now released, notify WaitForDeleteWallet, if any.
237237
{
238238
LOCK(g_wallet_release_mutex);
239239
if (g_unloading_wallet_set.erase(name) == 0) {
240-
// UnloadWallet was not called for this wallet, all done.
240+
// WaitForDeleteWallet was not called for this wallet, all done.
241241
return;
242242
}
243243
}
244244
g_wallet_release_cv.notify_all();
245245
}
246246

247-
void UnloadWallet(std::shared_ptr<CWallet>&& wallet)
247+
void WaitForDeleteWallet(std::shared_ptr<CWallet>&& wallet)
248248
{
249249
// Mark wallet for unloading.
250250
const std::string name = wallet->GetName();
@@ -4387,7 +4387,7 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
43874387
if (!RemoveWallet(context, wallet, /*load_on_start=*/std::nullopt, warnings)) {
43884388
return util::Error{_("Unable to unload the wallet before migrating")};
43894389
}
4390-
UnloadWallet(std::move(wallet));
4390+
WaitForDeleteWallet(std::move(wallet));
43914391
was_loaded = true;
43924392
} else {
43934393
// Check if the wallet is BDB
@@ -4531,7 +4531,7 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
45314531
error += _("\nUnable to cleanup failed migration");
45324532
return util::Error{error};
45334533
}
4534-
UnloadWallet(std::move(w));
4534+
WaitForDeleteWallet(std::move(w));
45354535
} else {
45364536
// Unloading for wallets in local context
45374537
assert(w.use_count() == 1);

src/wallet/wallet.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,9 @@ struct bilingual_str;
8383
namespace wallet {
8484
struct WalletContext;
8585

86-
//! Explicitly unload and delete the wallet.
87-
//! Blocks the current thread after signaling the unload intent so that all
88-
//! wallet pointer owners release the wallet.
89-
//! Note that, when blocking is not required, the wallet is implicitly unloaded
90-
//! by the shared pointer deleter.
91-
void UnloadWallet(std::shared_ptr<CWallet>&& wallet);
86+
//! Explicitly delete the wallet.
87+
//! Blocks the current thread until the wallet is destructed.
88+
void WaitForDeleteWallet(std::shared_ptr<CWallet>&& wallet);
9289

9390
bool AddWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet);
9491
bool RemoveWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);

0 commit comments

Comments
 (0)