wallet: Use shared pointer to retain wallet instance

This commit is contained in:
João Barbosa
2018-05-22 16:18:07 +01:00
parent 6916024768
commit 80b4910f7d
15 changed files with 239 additions and 139 deletions
+5 -6
View File
@@ -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;
}
}