Skip to content

Commit

Permalink
Use std::shared_ptr instead of boost::shared_ptr in ScriptForMining
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt authored and xanimo committed Apr 1, 2024
1 parent e6167c1 commit f2ac8a0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CReserveScript> coinbaseScript(new CReserveScript());
std::shared_ptr<CReserveScript> coinbaseScript = std::make_shared<CReserveScript>();
coinbaseScript->reserveScript = GetScriptForDestination(address.Get());

return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false, nMineAuxPow);
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3495,7 +3495,7 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx)

void CWallet::GetScriptForMining(std::shared_ptr<CReserveScript> &script)
{
std::shared_ptr<CReserveKey> rKey(new CReserveKey(this));
std::shared_ptr<CReserveKey> rKey = std::make_shared<CReserveKey>(this);
CPubKey pubkey;
if (!rKey->GetReservedKey(pubkey))
return;
Expand Down
15 changes: 12 additions & 3 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include <utility>
#include <vector>

#include <boost/shared_ptr.hpp>

extern CWallet* pwalletMain;

/**
Expand Down Expand Up @@ -674,6 +672,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
TxItems wtxOrdered;

int64_t nOrderPosNext;
std::map<uint256, int> mapRequestCount;

std::map<CTxDestination, CAddressBookData> mapAddressBook;

Expand Down Expand Up @@ -883,8 +882,18 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface

void UpdatedTransaction(const uint256 &hashTx) override;

void GetScriptForMining(std::shared_ptr<CReserveScript> &script) override;
void Inventory(const uint256 &hash) override
{
{
LOCK(cs_wallet);
std::map<uint256, int>::iterator mi = mapRequestCount.find(hash);
if (mi != mapRequestCount.end())
(*mi).second++;
}
}

void GetScriptForMining(std::shared_ptr<CReserveScript> &script) override;

unsigned int GetKeyPoolSize()
{
AssertLockHeld(cs_wallet); // setKeyPool
Expand Down

0 comments on commit f2ac8a0

Please sign in to comment.