aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2024-08-13 23:00:45 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2024-08-14 16:12:18 -0300
commit8872b4a6ca91a83bf8d5a118fb808c043b9e879d (patch)
tree6e19824c205dc202a0af1dacae304c27cd4a54e2 /src/wallet
parent5d15485aafefdc759ba97e039bb1b9ccac267358 (diff)
downloadbitcoin-8872b4a6ca91a83bf8d5a118fb808c043b9e879d.tar.xz
wallet: rename UnloadWallet to WaitForDeleteWallet
And update function's documentation.
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/load.cpp2
-rw-r--r--src/wallet/rpc/wallet.cpp2
-rw-r--r--src/wallet/test/util.cpp2
-rw-r--r--src/wallet/test/wallet_tests.cpp2
-rw-r--r--src/wallet/wallet.cpp10
-rw-r--r--src/wallet/wallet.h9
6 files changed, 12 insertions, 15 deletions
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp
index fe35f6b223..e26347d437 100644
--- a/src/wallet/load.cpp
+++ b/src/wallet/load.cpp
@@ -178,7 +178,7 @@ void UnloadWallets(WalletContext& context)
wallets.pop_back();
std::vector<bilingual_str> warnings;
RemoveWallet(context, wallet, /* load_on_start= */ std::nullopt, warnings);
- UnloadWallet(std::move(wallet));
+ WaitForDeleteWallet(std::move(wallet));
}
}
} // namespace wallet
diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp
index ae1c67ef2a..83e386b3d9 100644
--- a/src/wallet/rpc/wallet.cpp
+++ b/src/wallet/rpc/wallet.cpp
@@ -495,7 +495,7 @@ static RPCHelpMan unloadwallet()
}
}
- UnloadWallet(std::move(wallet));
+ WaitForDeleteWallet(std::move(wallet));
UniValue result(UniValue::VOBJ);
PushWarnings(warnings, result);
diff --git a/src/wallet/test/util.cpp b/src/wallet/test/util.cpp
index b21a9a601d..ec6c9e6f3f 100644
--- a/src/wallet/test/util.cpp
+++ b/src/wallet/test/util.cpp
@@ -74,7 +74,7 @@ void TestUnloadWallet(std::shared_ptr<CWallet>&& wallet)
// Calls SyncWithValidationInterfaceQueue
wallet->chain().waitForNotificationsIfTipChanged({});
wallet->m_chain_notifications_handler.reset();
- UnloadWallet(std::move(wallet));
+ WaitForDeleteWallet(std::move(wallet));
}
std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database)
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
index 53f3bcc421..44ffddb168 100644
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -889,7 +889,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWalletWithoutChain, BasicTestingSetup)
context.args = &m_args;
auto wallet = TestLoadWallet(context);
BOOST_CHECK(wallet);
- UnloadWallet(std::move(wallet));
+ WaitForDeleteWallet(std::move(wallet));
}
BOOST_FIXTURE_TEST_CASE(RemoveTxs, TestChain100Setup)
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 8abdd336a2..4734fc7b1d 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -233,18 +233,18 @@ static void ReleaseWallet(CWallet* wallet)
wallet->WalletLogPrintf("Releasing wallet\n");
wallet->Flush();
delete wallet;
- // Wallet is now released, notify UnloadWallet, if any.
+ // Wallet is now released, notify WaitForDeleteWallet, if any.
{
LOCK(g_wallet_release_mutex);
if (g_unloading_wallet_set.erase(name) == 0) {
- // UnloadWallet was not called for this wallet, all done.
+ // WaitForDeleteWallet was not called for this wallet, all done.
return;
}
}
g_wallet_release_cv.notify_all();
}
-void UnloadWallet(std::shared_ptr<CWallet>&& wallet)
+void WaitForDeleteWallet(std::shared_ptr<CWallet>&& wallet)
{
// Mark wallet for unloading.
const std::string name = wallet->GetName();
@@ -4387,7 +4387,7 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
if (!RemoveWallet(context, wallet, /*load_on_start=*/std::nullopt, warnings)) {
return util::Error{_("Unable to unload the wallet before migrating")};
}
- UnloadWallet(std::move(wallet));
+ WaitForDeleteWallet(std::move(wallet));
was_loaded = true;
} else {
// Check if the wallet is BDB
@@ -4531,7 +4531,7 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
error += _("\nUnable to cleanup failed migration");
return util::Error{error};
}
- UnloadWallet(std::move(w));
+ WaitForDeleteWallet(std::move(w));
} else {
// Unloading for wallets in local context
assert(w.use_count() == 1);
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 984a2d9c48..3ea1cf48b2 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -83,12 +83,9 @@ struct bilingual_str;
namespace wallet {
struct WalletContext;
-//! Explicitly unload and delete the wallet.
-//! Blocks the current thread after signaling the unload intent so that all
-//! wallet pointer owners release the wallet.
-//! Note that, when blocking is not required, the wallet is implicitly unloaded
-//! by the shared pointer deleter.
-void UnloadWallet(std::shared_ptr<CWallet>&& wallet);
+//! Explicitly delete the wallet.
+//! Blocks the current thread until the wallet is destructed.
+void WaitForDeleteWallet(std::shared_ptr<CWallet>&& wallet);
bool AddWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet);
bool RemoveWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);