From 1c95e2f9c94f172ddddedeb1358953992f39f8bd 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 | 7 +++---- src/validationinterface.h | 5 ++--- src/wallet/wallet.cpp | 4 ++-- src/wallet/wallet.h | 4 +--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index cf7ca650b9b..d234bb69aec 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -27,7 +27,6 @@ #include #include -#include #include @@ -95,7 +94,7 @@ UniValue getnetworkhashps(const JSONRPCRequest& request) return GetNetworkHashPS(request.params.size() > 0 ? request.params[0].get_int() : 120, request.params.size() > 1 ? request.params[1].get_int() : -1); } -UniValue generateBlocks(boost::shared_ptr coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript) +UniValue generateBlocks(std::shared_ptr coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript) { static const int nInnerLoopCount = 0x10000; int nHeightStart = 0; @@ -167,7 +166,7 @@ UniValue generate(const JSONRPCRequest& request) nMaxTries = request.params[1].get_int(); } - boost::shared_ptr coinbaseScript; + std::shared_ptr coinbaseScript; GetMainSignals().ScriptForMining(coinbaseScript); // If the keypool is exhausted, no script is returned at all. Catch this. @@ -208,7 +207,7 @@ UniValue generatetoaddress(const JSONRPCRequest& request) if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address"); - boost::shared_ptr coinbaseScript(new CReserveScript()); + std::shared_ptr coinbaseScript = std::make_shared(); coinbaseScript->reserveScript = GetScriptForDestination(address.Get()); return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false); diff --git a/src/validationinterface.h b/src/validationinterface.h index baa04fe312a..083c136f2c6 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -7,7 +7,6 @@ #define BITCOIN_VALIDATIONINTERFACE_H #include -#include #include #include "primitives/transaction.h" // CTransaction(Ref) @@ -42,7 +41,7 @@ protected: virtual void Inventory(const uint256 &hash) {} virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {} virtual void BlockChecked(const CBlock&, const CValidationState&) {} - virtual void GetScriptForMining(boost::shared_ptr&) {}; + virtual void GetScriptForMining(std::shared_ptr&) {}; virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr& block) {}; friend void ::RegisterValidationInterface(CValidationInterface*); friend void ::UnregisterValidationInterface(CValidationInterface*); @@ -77,7 +76,7 @@ struct CMainSignals { */ boost::signals2::signal BlockChecked; /** Notifies listeners that a key for mining is required (coinbase) */ - boost::signals2::signal&)> ScriptForMining; + boost::signals2::signal&)> ScriptForMining; /** * Notifies listeners that a block which builds directly on our current tip * has been received and connected to the headers tree, though not validated yet */ diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b04037774d4..dc145fd3d24 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3376,9 +3376,9 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx) } } -void CWallet::GetScriptForMining(boost::shared_ptr &script) +void CWallet::GetScriptForMining(std::shared_ptr &script) { - boost::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 127ffd6cf37..daae9303994 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -28,8 +28,6 @@ #include #include -#include - extern CWallet* pwalletMain; /** @@ -963,7 +961,7 @@ public: } } - void GetScriptForMining(boost::shared_ptr &script) override; + void GetScriptForMining(std::shared_ptr &script) override; unsigned int GetKeyPoolSize() {