From f2ac8a04fc306aa1c1154874f51e8a7257020f88 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 19 Jan 2017 16:15:41 -0500 Subject: [PATCH] Use std::shared_ptr instead of boost::shared_ptr in ScriptForMining --- src/rpc/mining.cpp | 2 +- src/wallet/wallet.cpp | 2 +- src/wallet/wallet.h | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 191fd98b0c3..e07d22ac506 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -242,7 +242,7 @@ UniValue generatetoaddress(const JSONRPCRequest& request) if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address"); - std::shared_ptr coinbaseScript(new CReserveScript()); + std::shared_ptr coinbaseScript = std::make_shared(); coinbaseScript->reserveScript = GetScriptForDestination(address.Get()); return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false, nMineAuxPow); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 7b9f9ead9dd..a609b7c9351 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3495,7 +3495,7 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx) void CWallet::GetScriptForMining(std::shared_ptr &script) { - std::shared_ptr rKey(new CReserveKey(this)); + std::shared_ptr rKey = std::make_shared(this); CPubKey pubkey; if (!rKey->GetReservedKey(pubkey)) return; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index bb1456bea3b..16834b859a7 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -32,8 +32,6 @@ #include #include -#include - extern CWallet* pwalletMain; /** @@ -674,6 +672,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface TxItems wtxOrdered; int64_t nOrderPosNext; + std::map mapRequestCount; std::map mapAddressBook; @@ -883,8 +882,18 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface void UpdatedTransaction(const uint256 &hashTx) override; - void GetScriptForMining(std::shared_ptr &script) override; + void Inventory(const uint256 &hash) override + { + { + LOCK(cs_wallet); + std::map::iterator mi = mapRequestCount.find(hash); + if (mi != mapRequestCount.end()) + (*mi).second++; + } + } + void GetScriptForMining(std::shared_ptr &script) override; + unsigned int GetKeyPoolSize() { AssertLockHeld(cs_wallet); // setKeyPool