From ddc93557ad0cf8e433df850d38710828ccd99c16 Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Mon, 2 Mar 2020 16:23:04 +0900 Subject: wallet: make CanGenerateKeys() const This method simply checks if HD is or can be enabled and does not require mutability. --- src/wallet/scriptpubkeyman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wallet/scriptpubkeyman.cpp') diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 0c95ab29b..5f8e5ac97 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -973,7 +973,7 @@ void LegacyScriptPubKeyMan::LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime); } -bool LegacyScriptPubKeyMan::CanGenerateKeys() +bool LegacyScriptPubKeyMan::CanGenerateKeys() const { // A wallet can generate keys if it has an HD seed (IsHDEnabled) or it is a non-HD wallet (pre FEATURE_HD) LOCK(cs_KeyStore); -- cgit v1.2.3 From 037fa770eb1ed5152b3ef2c5d3fb2a812d3ef944 Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Mon, 2 Mar 2020 16:33:45 +0900 Subject: wallet: make KeypoolCountExternalKeys() const This method returns the sum of the key pool sizes. It does no modification. --- src/wallet/scriptpubkeyman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wallet/scriptpubkeyman.cpp') diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 5f8e5ac97..defe2f0a9 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -459,7 +459,7 @@ int64_t LegacyScriptPubKeyMan::GetOldestKeyPoolTime() return oldestKey; } -size_t LegacyScriptPubKeyMan::KeypoolCountExternalKeys() +size_t LegacyScriptPubKeyMan::KeypoolCountExternalKeys() const { LOCK(cs_KeyStore); return setExternalKeyPool.size() + set_pre_split_keypool.size(); -- cgit v1.2.3 From 8cd0b86340870d8f359e4ae26880e03ea36818ab Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Mon, 2 Mar 2020 16:35:58 +0900 Subject: wallet: make CanGetAddresses() const CWallet::CanGetAddresses() is used to check whether the wallet has available or is able to produce keys for addresses. It uses the ScriptPubKeyMan::CanGetAddresses(), which in turn uses the const KeypoolCountExternalKeys() method, all which do counting and no modifications. --- src/wallet/scriptpubkeyman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wallet/scriptpubkeyman.cpp') diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index defe2f0a9..8ff00e802 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -358,7 +358,7 @@ bool LegacyScriptPubKeyMan::IsHDEnabled() const return !hdChain.seed_id.IsNull(); } -bool LegacyScriptPubKeyMan::CanGetAddresses(bool internal) +bool LegacyScriptPubKeyMan::CanGetAddresses(bool internal) const { LOCK(cs_KeyStore); // Check if the keypool has keys -- cgit v1.2.3 From 227b9dd2d6e1914edfec108af6bec5f12d9f6f39 Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Mon, 2 Mar 2020 16:54:59 +0900 Subject: wallet/spkm: make GetOldestKeyPoolTime() const The method checks the oldest key time for key pools and returns the oldest. It does no modifications. --- src/wallet/scriptpubkeyman.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wallet/scriptpubkeyman.cpp') diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 8ff00e802..8851d0af3 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -441,7 +441,7 @@ static int64_t GetOldestKeyTimeInPool(const std::set& setKeyPool, Walle return keypool.nTime; } -int64_t LegacyScriptPubKeyMan::GetOldestKeyPoolTime() +int64_t LegacyScriptPubKeyMan::GetOldestKeyPoolTime() const { LOCK(cs_KeyStore); -- cgit v1.2.3