aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.h
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2017-04-19 12:55:32 -0400
committerMatt Corallo <git@bluematt.me>2017-07-14 21:25:21 -0400
commit4a3fc35629a2820cecd15898f112fa730e5adcec (patch)
tree189446bca88ad269279c6eb87afa295674fcb25e /src/wallet/wallet.h
parentd083bd9b9c5249f21b8b7e4abd7aee48a25806b1 (diff)
downloadbitcoin-4a3fc35629a2820cecd15898f112fa730e5adcec.tar.xz
Track keypool entries as internal vs external in memory
This resolves a super minor performance regressions in several keypool-handling functions
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r--src/wallet/wallet.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index ad606b8535..c1e05e8611 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -696,7 +696,8 @@ private:
/* HD derive new child key (on internal or external chain) */
void DeriveNewChildKey(CKeyMetadata& metadata, CKey& secret, bool internal = false);
- std::set<int64_t> setKeyPool;
+ std::set<int64_t> setInternalKeyPool;
+ std::set<int64_t> setExternalKeyPool;
int64_t nTimeFirstKey;
@@ -741,7 +742,11 @@ public:
void LoadKeyPool(int nIndex, const CKeyPool &keypool)
{
- setKeyPool.insert(nIndex);
+ if (keypool.fInternal) {
+ setInternalKeyPool.insert(nIndex);
+ } else {
+ setExternalKeyPool.insert(nIndex);
+ }
// If no metadata exists yet, create a default with the pool key's
// creation time. Note that this may be overwritten by actually
@@ -970,9 +975,9 @@ public:
bool NewKeyPool();
size_t KeypoolCountExternalKeys();
bool TopUpKeyPool(unsigned int kpSize = 0);
- void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool internal);
+ void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRequestedInternal);
void KeepKey(int64_t nIndex);
- void ReturnKey(int64_t nIndex);
+ void ReturnKey(int64_t nIndex, bool fInternal);
bool GetKeyFromPool(CPubKey &key, bool internal = false);
int64_t GetOldestKeyPoolTime();
void GetAllReserveKeys(std::set<CKeyID>& setAddress) const;
@@ -1026,8 +1031,8 @@ public:
unsigned int GetKeyPoolSize()
{
- AssertLockHeld(cs_wallet); // setKeyPool
- return setKeyPool.size();
+ AssertLockHeld(cs_wallet); // set{Ex,In}ternalKeyPool
+ return setInternalKeyPool.size() + setExternalKeyPool.size();
}
bool SetDefaultKey(const CPubKey &vchPubKey);
@@ -1131,11 +1136,13 @@ protected:
CWallet* pwallet;
int64_t nIndex;
CPubKey vchPubKey;
+ bool fInternal;
public:
CReserveKey(CWallet* pwalletIn)
{
nIndex = -1;
pwallet = pwalletIn;
+ fInternal = false;
}
CReserveKey() = default;