Skip to content

Commit 9819ad6

Browse files
committed
[rpc] simplify generate RPC
Removes dead code from after the generate method was removed
1 parent 6a135fb commit 9819ad6

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
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.

0 commit comments

Comments
 (0)