Use std::shared_ptr instead of boost::shared_ptr in ScriptForMining

This commit is contained in:
Matt Corallo 2017-01-19 16:15:41 -05:00
parent 91f1e6ce5e
commit 1c95e2f9c9
4 changed files with 8 additions and 12 deletions

View File

@ -27,7 +27,6 @@
#include <stdint.h> #include <stdint.h>
#include <boost/assign/list_of.hpp> #include <boost/assign/list_of.hpp>
#include <boost/shared_ptr.hpp>
#include <univalue.h> #include <univalue.h>
@ -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); 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<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript) UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
{ {
static const int nInnerLoopCount = 0x10000; static const int nInnerLoopCount = 0x10000;
int nHeightStart = 0; int nHeightStart = 0;
@ -167,7 +166,7 @@ UniValue generate(const JSONRPCRequest& request)
nMaxTries = request.params[1].get_int(); nMaxTries = request.params[1].get_int();
} }
boost::shared_ptr<CReserveScript> coinbaseScript; std::shared_ptr<CReserveScript> coinbaseScript;
GetMainSignals().ScriptForMining(coinbaseScript); GetMainSignals().ScriptForMining(coinbaseScript);
// If the keypool is exhausted, no script is returned at all. Catch this. // 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()) if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
boost::shared_ptr<CReserveScript> coinbaseScript(new CReserveScript()); std::shared_ptr<CReserveScript> coinbaseScript = std::make_shared<CReserveScript>();
coinbaseScript->reserveScript = GetScriptForDestination(address.Get()); coinbaseScript->reserveScript = GetScriptForDestination(address.Get());
return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false); return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false);

View File

@ -7,7 +7,6 @@
#define BITCOIN_VALIDATIONINTERFACE_H #define BITCOIN_VALIDATIONINTERFACE_H
#include <boost/signals2/signal.hpp> #include <boost/signals2/signal.hpp>
#include <boost/shared_ptr.hpp>
#include <memory> #include <memory>
#include "primitives/transaction.h" // CTransaction(Ref) #include "primitives/transaction.h" // CTransaction(Ref)
@ -42,7 +41,7 @@ protected:
virtual void Inventory(const uint256 &hash) {} virtual void Inventory(const uint256 &hash) {}
virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {} virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {}
virtual void BlockChecked(const CBlock&, const CValidationState&) {} virtual void BlockChecked(const CBlock&, const CValidationState&) {}
virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {}; virtual void GetScriptForMining(std::shared_ptr<CReserveScript>&) {};
virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {}; virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {};
friend void ::RegisterValidationInterface(CValidationInterface*); friend void ::RegisterValidationInterface(CValidationInterface*);
friend void ::UnregisterValidationInterface(CValidationInterface*); friend void ::UnregisterValidationInterface(CValidationInterface*);
@ -77,7 +76,7 @@ struct CMainSignals {
*/ */
boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked; boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;
/** Notifies listeners that a key for mining is required (coinbase) */ /** Notifies listeners that a key for mining is required (coinbase) */
boost::signals2::signal<void (boost::shared_ptr<CReserveScript>&)> ScriptForMining; boost::signals2::signal<void (std::shared_ptr<CReserveScript>&)> ScriptForMining;
/** /**
* Notifies listeners that a block which builds directly on our current tip * 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 */ * has been received and connected to the headers tree, though not validated yet */

View File

@ -3376,9 +3376,9 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx)
} }
} }
void CWallet::GetScriptForMining(boost::shared_ptr<CReserveScript> &script) void CWallet::GetScriptForMining(std::shared_ptr<CReserveScript> &script)
{ {
boost::shared_ptr<CReserveKey> rKey(new CReserveKey(this)); std::shared_ptr<CReserveKey> rKey = std::make_shared<CReserveKey>(this);
CPubKey pubkey; CPubKey pubkey;
if (!rKey->GetReservedKey(pubkey)) if (!rKey->GetReservedKey(pubkey))
return; return;

View File

@ -28,8 +28,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <boost/shared_ptr.hpp>
extern CWallet* pwalletMain; extern CWallet* pwalletMain;
/** /**
@ -963,7 +961,7 @@ public:
} }
} }
void GetScriptForMining(boost::shared_ptr<CReserveScript> &script) override; void GetScriptForMining(std::shared_ptr<CReserveScript> &script) override;
unsigned int GetKeyPoolSize() unsigned int GetKeyPoolSize()
{ {