refactor: Wallet stats logging in its own function

This will avoid repetition when wallet creation and loading are
separated.
This commit is contained in:
David Gumberg
2025-05-27 16:46:00 -07:00
parent a9d64cd49c
commit bc69070416
2 changed files with 9 additions and 6 deletions

View File

@@ -3093,12 +3093,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
return nullptr;
}
{
LOCK(walletInstance->cs_wallet);
walletInstance->WalletLogPrintf("setKeyPool.size() = %u\n", walletInstance->GetKeyPoolSize());
walletInstance->WalletLogPrintf("mapWallet.size() = %u\n", walletInstance->mapWallet.size());
walletInstance->WalletLogPrintf("m_address_book.size() = %u\n", walletInstance->m_address_book.size());
}
WITH_LOCK(walletInstance->cs_wallet, walletInstance->LogStats());
return walletInstance;
}

View File

@@ -940,6 +940,14 @@ public:
LogInfo("[%s] %s", LogName(), tfm::format(wallet_fmt, params...));
};
void LogStats() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
{
AssertLockHeld(cs_wallet);
WalletLogPrintf("setKeyPool.size() = %u\n", GetKeyPoolSize());
WalletLogPrintf("mapWallet.size() = %u\n", mapWallet.size());
WalletLogPrintf("m_address_book.size() = %u\n", m_address_book.size());
};
//! Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers
std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;
bool IsActiveScriptPubKeyMan(const ScriptPubKeyMan& spkm) const;