wallet: Use shared pointer to retain wallet instance
This commit is contained in:
+5
-6
@@ -226,7 +226,7 @@ bool WalletInit::Open() const
|
||||
}
|
||||
|
||||
for (const std::string& walletFile : gArgs.GetArgs("-wallet")) {
|
||||
CWallet * const pwallet = CWallet::CreateWalletFromFile(walletFile, fs::absolute(walletFile, GetWalletDir()));
|
||||
std::shared_ptr<CWallet> pwallet = CWallet::CreateWalletFromFile(walletFile, fs::absolute(walletFile, GetWalletDir()));
|
||||
if (!pwallet) {
|
||||
return false;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ bool WalletInit::Open() const
|
||||
|
||||
void WalletInit::Start(CScheduler& scheduler) const
|
||||
{
|
||||
for (CWallet* pwallet : GetWallets()) {
|
||||
for (const std::shared_ptr<CWallet>& pwallet : GetWallets()) {
|
||||
pwallet->postInitProcess();
|
||||
}
|
||||
|
||||
@@ -248,22 +248,21 @@ void WalletInit::Start(CScheduler& scheduler) const
|
||||
|
||||
void WalletInit::Flush() const
|
||||
{
|
||||
for (CWallet* pwallet : GetWallets()) {
|
||||
for (const std::shared_ptr<CWallet>& pwallet : GetWallets()) {
|
||||
pwallet->Flush(false);
|
||||
}
|
||||
}
|
||||
|
||||
void WalletInit::Stop() const
|
||||
{
|
||||
for (CWallet* pwallet : GetWallets()) {
|
||||
for (const std::shared_ptr<CWallet>& pwallet : GetWallets()) {
|
||||
pwallet->Flush(true);
|
||||
}
|
||||
}
|
||||
|
||||
void WalletInit::Close() const
|
||||
{
|
||||
for (CWallet* pwallet : GetWallets()) {
|
||||
for (const std::shared_ptr<CWallet>& pwallet : GetWallets()) {
|
||||
RemoveWallet(pwallet);
|
||||
delete pwallet;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user