Skip to content

Commit adc55db

Browse files
committed
Merge #15748: [rpc] remove dead mining code
1b46a48 [cleanup] Remove unused CReserveKey (John Newbery) 9819ad6 [rpc] simplify generate RPC (John Newbery) Pull request description: Removes dead code from after the generate method was removed ACKs for commit 1b46a4: MarcoFalke: utACK 1b46a48 meshcollider: utACK bitcoin/bitcoin@1b46a48 scravy: utACK 1b46a48 Empact: utACK bitcoin/bitcoin@1b46a48 Tree-SHA512: d1fab1bf76ac3036b85cf33be89868bc016f912575545ecaa16f958397b0ec4f1ce4de8fe254d4f21aabeea9c83a8928530cc520de26af0d1a8bdb4ca0f2cb77
2 parents 66ce95a + 1b46a48 commit adc55db

File tree

6 files changed

+7
-40
lines changed

6 files changed

+7
-40
lines changed

src/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ BITCOIN_CORE_H = \
174174
reverselock.h \
175175
rpc/blockchain.h \
176176
rpc/client.h \
177-
rpc/mining.h \
178177
rpc/protocol.h \
179178
rpc/server.h \
180179
rpc/rawtransaction_util.h \

src/rpc/mining.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
#include <policy/fees.h>
1717
#include <pow.h>
1818
#include <rpc/blockchain.h>
19-
#include <rpc/mining.h>
2019
#include <rpc/server.h>
2120
#include <rpc/util.h>
21+
#include <script/script.h>
2222
#include <shutdown.h>
2323
#include <txmempool.h>
24+
#include <univalue.h>
2425
#include <util/fees.h>
2526
#include <util/strencodings.h>
2627
#include <util/system.h>
@@ -100,7 +101,7 @@ static UniValue getnetworkhashps(const JSONRPCRequest& request)
100101
return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1);
101102
}
102103

103-
UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
104+
static UniValue generateBlocks(const CScript& coinbase_script, int nGenerate, uint64_t nMaxTries)
104105
{
105106
static const int nInnerLoopCount = 0x10000;
106107
int nHeightEnd = 0;
@@ -115,7 +116,7 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
115116
UniValue blockHashes(UniValue::VARR);
116117
while (nHeight < nHeightEnd && !ShutdownRequested())
117118
{
118-
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(coinbaseScript->reserveScript));
119+
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(coinbase_script));
119120
if (!pblocktemplate.get())
120121
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
121122
CBlock *pblock = &pblocktemplate->block;
@@ -138,12 +139,6 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
138139
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
139140
++nHeight;
140141
blockHashes.push_back(pblock->GetHash().GetHex());
141-
142-
//mark script as important because it was used at least for one coinbase output if the script came from the wallet
143-
if (keepScript)
144-
{
145-
coinbaseScript->KeepScript();
146-
}
147142
}
148143
return blockHashes;
149144
}
@@ -181,10 +176,9 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
181176
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
182177
}
183178

184-
std::shared_ptr<CReserveScript> coinbaseScript = std::make_shared<CReserveScript>();
185-
coinbaseScript->reserveScript = GetScriptForDestination(destination);
179+
CScript coinbase_script = GetScriptForDestination(destination);
186180

187-
return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false);
181+
return generateBlocks(coinbase_script, nGenerate, nMaxTries);
188182
}
189183

190184
static UniValue getmininginfo(const JSONRPCRequest& request)

src/rpc/mining.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/script/script.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,4 @@ struct CScriptWitness
581581
std::string ToString() const;
582582
};
583583

584-
class CReserveScript
585-
{
586-
public:
587-
CScript reserveScript;
588-
virtual void KeepScript() {}
589-
CReserveScript() {}
590-
virtual ~CReserveScript() {}
591-
};
592-
593584
#endif // BITCOIN_SCRIPT_SCRIPT_H

src/validationinterface.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class CBlockIndex;
1818
struct CBlockLocator;
1919
class CBlockIndex;
2020
class CConnman;
21-
class CReserveScript;
2221
class CValidationInterface;
2322
class CValidationState;
2423
class uint256;

src/wallet/wallet.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ class CWallet final : public CCryptoKeyStore, private interfaces::Chain::Notific
12191219
void MaybeResendWalletTxs();
12201220

12211221
/** A key allocated from the key pool. */
1222-
class CReserveKey final : public CReserveScript
1222+
class CReserveKey
12231223
{
12241224
protected:
12251225
CWallet* pwallet;
@@ -1244,7 +1244,6 @@ class CReserveKey final : public CReserveScript
12441244
void ReturnKey();
12451245
bool GetReservedKey(CPubKey &pubkey, bool internal = false);
12461246
void KeepKey();
1247-
void KeepScript() override { KeepKey(); }
12481247
};
12491248

12501249
/** RAII object to check and reserve a wallet rescan */

0 commit comments

Comments
 (0)