mining: replace boost::shared_ptr with std::shared_ptr

Throughout the codebase we use std::shared_ptr, except for some
instances in the miner code, where we use boost::shared_ptr for
sharing a wallet address with the miner and rpc across threads.

This patch removes all usage of boost::shared_ptr to instead use
std::shared_ptr, to reduce exposure to multiple shared pointer
implementations.
This commit is contained in:
Patrick Lodder 2023-07-17 11:49:54 -04:00
parent 4c441c1e8f
commit 0d39941515
No known key found for this signature in database
GPG Key ID: 7C523F5FBABE80E7
6 changed files with 10 additions and 16 deletions

View File

@ -12,8 +12,6 @@
#include "serialize.h"
#include "uint256.h"
#include <boost/shared_ptr.hpp>
/** Nodes collect new transactions into a block, hash them into a hash tree,
* and scan through nonce values to make the block's hash satisfy proof-of-work
* requirements. When they solve the proof-of-work, they broadcast the block
@ -25,7 +23,7 @@ class CBlockHeader : public CPureBlockHeader
{
public:
// auxpow (if this is a merge-minded block)
boost::shared_ptr<CAuxPow> auxpow;
std::shared_ptr<CAuxPow> auxpow;
CBlockHeader()
{

View File

@ -27,7 +27,6 @@
#include <stdint.h>
#include <boost/assign/list_of.hpp>
#include <boost/shared_ptr.hpp>
#include <univalue.h>
@ -97,7 +96,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<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript, int nMineAuxPow)
UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript, int nMineAuxPow)
{
// Dogecoin: Never mine witness tx
const bool fMineWitnessTx = false;
@ -198,7 +197,7 @@ UniValue generate(const JSONRPCRequest& request)
nMineAuxPow = request.params[2].get_int();
}
boost::shared_ptr<CReserveScript> coinbaseScript;
std::shared_ptr<CReserveScript> coinbaseScript;
GetMainSignals().ScriptForMining(coinbaseScript);
// If the keypool is exhausted, no script is returned at all. Catch this.
@ -245,7 +244,7 @@ UniValue generatetoaddress(const JSONRPCRequest& request)
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
boost::shared_ptr<CReserveScript> coinbaseScript(new CReserveScript());
std::shared_ptr<CReserveScript> coinbaseScript(new CReserveScript());
coinbaseScript->reserveScript = GetScriptForDestination(address.Get());
return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false, nMineAuxPow);
@ -1164,7 +1163,7 @@ UniValue getauxblockbip22(const JSONRPCRequest& request)
+ HelpExampleRpc("getauxblock", "")
);
boost::shared_ptr<CReserveScript> coinbaseScript;
std::shared_ptr<CReserveScript> coinbaseScript;
GetMainSignals().ScriptForMining(coinbaseScript);
// If the keypool is exhausted, no script is returned at all. Catch this.

View File

@ -19,7 +19,6 @@
#include <boost/bind/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/thread.hpp>
#include <boost/algorithm/string/case_conv.hpp> // for to_upper()

View File

@ -8,7 +8,6 @@
#define BITCOIN_VALIDATIONINTERFACE_H
#include <boost/signals2/signal.hpp>
#include <boost/shared_ptr.hpp>
#include <memory>
class CBlock;
@ -39,7 +38,7 @@ protected:
virtual void UpdatedTransaction(const uint256 &hash) {}
virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {}
virtual void BlockChecked(const CBlock&, const CValidationState&) {}
virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {};
virtual void GetScriptForMining(std::shared_ptr<CReserveScript>&) {};
virtual void ResetRequestCount(const uint256 &hash) {};
virtual void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& block) {};
friend void ::RegisterValidationInterface(CValidationInterface*);
@ -70,7 +69,7 @@ struct CMainSignals {
/** Notifies listeners of a block validation result */
boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;
/** 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 has been successfully mined */
boost::signals2::signal<void (const uint256 &)> BlockFound;
/**

View File

@ -3458,9 +3458,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(new CReserveKey(this));
CPubKey pubkey;
if (!rKey->GetReservedKey(pubkey))
return;

View File

@ -32,7 +32,6 @@
#include <utility>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
extern CWallet* pwalletMain;
@ -878,7 +877,7 @@ public:
void UpdatedTransaction(const uint256 &hashTx) override;
void GetScriptForMining(boost::shared_ptr<CReserveScript> &script) override;
void GetScriptForMining(std::shared_ptr<CReserveScript> &script) override;
unsigned int GetKeyPoolSize()
{