diff options
author | Jeff Garzik <jgarzik@bitpay.com> | 2013-06-25 16:07:29 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@bitpay.com> | 2013-06-25 16:07:29 -0400 |
commit | 13dd2d090e1acf8895854cedea18e38a6278c7ea (patch) | |
tree | 6aab366e467151d693ea9d1a90110c86e5f08058 | |
parent | 481d89979457d69da07edd99fba451fd42a47f5c (diff) |
CWallet::TopUpKeyPool() takes optional pool size argument
Also, GetKeyPoolSize() now returns an accurate type, unsigned int.
-rw-r--r-- | src/rpcwallet.cpp | 2 | ||||
-rw-r--r-- | src/wallet.cpp | 9 | ||||
-rw-r--r-- | src/wallet.h | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 5388bd4d84..7d3cfad76a 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -81,7 +81,7 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.push_back(Pair("testnet", TestNet())); obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime())); - obj.push_back(Pair("keypoolsize", pwalletMain->GetKeyPoolSize())); + obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee))); if (pwalletMain->IsCrypted()) obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime)); diff --git a/src/wallet.cpp b/src/wallet.cpp index 488787f967..e64d3150a3 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1553,7 +1553,7 @@ bool CWallet::NewKeyPool() return true; } -bool CWallet::TopUpKeyPool() +bool CWallet::TopUpKeyPool(unsigned int kpSize) { { LOCK(cs_wallet); @@ -1564,7 +1564,12 @@ bool CWallet::TopUpKeyPool() CWalletDB walletdb(strWalletFile); // Top up key pool - unsigned int nTargetSize = max(GetArg("-keypool", 100), 0LL); + unsigned int nTargetSize; + if (kpSize > 0) + nTargetSize = kpSize; + else + nTargetSize = max(GetArg("-keypool", 100), 0LL); + while (setKeyPool.size() < (nTargetSize + 1)) { int64 nEnd = 1; diff --git a/src/wallet.h b/src/wallet.h index 36b3608fb0..cd9bf54cc5 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -195,7 +195,7 @@ public: std::string SendMoneyToDestination(const CTxDestination &address, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false); bool NewKeyPool(); - bool TopUpKeyPool(); + bool TopUpKeyPool(unsigned int kpSize = 0); int64 AddReserveKey(const CKeyPool& keypool); void ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool); void KeepKey(int64 nIndex); @@ -292,7 +292,7 @@ public: } } - int GetKeyPoolSize() + unsigned int GetKeyPoolSize() { return setKeyPool.size(); } |