MCPcopy Create free account
hub / github.com/ElementsProject/elements / UnloadWallet

Function UnloadWallet

src/wallet/wallet.cpp:212–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212void UnloadWallet(std::shared_ptr<CWallet>&& wallet)
213{
214 // Mark wallet for unloading.
215 const std::string name = wallet->GetName();
216 {
217 LOCK(g_wallet_release_mutex);
218 auto it = g_unloading_wallet_set.insert(name);
219 assert(it.second);
220 }
221 // The wallet can be in use so it's not possible to explicitly unload here.
222 // Notify the unload intent so that all remaining shared pointers are
223 // released.
224 wallet->NotifyUnload();
225
226 // Time to ditch our shared_ptr and wait for ReleaseWallet call.
227 wallet.reset();
228 {
229 WAIT_LOCK(g_wallet_release_mutex, lock);
230 while (g_unloading_wallet_set.count(name) == 1) {
231 g_wallet_release_cv.wait(lock);
232 }
233 }
234}
235
236namespace {
237std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings)

Callers 5

UnloadWalletsFunction · 0.85
TestUnloadWalletFunction · 0.85
BOOST_FIXTURE_TEST_CASEFunction · 0.85
~FuzzedWalletMethod · 0.85
unloadwalletFunction · 0.85

Calls 5

countMethod · 0.80
waitMethod · 0.80
GetNameMethod · 0.45
insertMethod · 0.45
resetMethod · 0.45

Tested by 3

TestUnloadWalletFunction · 0.68
BOOST_FIXTURE_TEST_CASEFunction · 0.68
~FuzzedWalletMethod · 0.68