Merge #15748: [rpc] remove dead mining code

1b46a4889 [cleanup] Remove unused CReserveKey (John Newbery)
9819ad6d0 [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 1b46a4889f
  meshcollider:
    utACK 1b46a4889f
  scravy:
    utACK 1b46a48
  Empact:
    utACK 1b46a4889f

Tree-SHA512: d1fab1bf76ac3036b85cf33be89868bc016f912575545ecaa16f958397b0ec4f1ce4de8fe254d4f21aabeea9c83a8928530cc520de26af0d1a8bdb4ca0f2cb77
This commit is contained in:
MeshCollider 2019-04-14 16:08:47 +12:00
commit adc55dbac5
No known key found for this signature in database
GPG key ID: D300116E1C875A3D
6 changed files with 7 additions and 40 deletions

View file

@ -174,7 +174,6 @@ BITCOIN_CORE_H = \
reverselock.h \
rpc/blockchain.h \
rpc/client.h \
rpc/mining.h \
rpc/protocol.h \
rpc/server.h \
rpc/rawtransaction_util.h \

View file

@ -16,11 +16,12 @@
#include <policy/fees.h>
#include <pow.h>
#include <rpc/blockchain.h>
#include <rpc/mining.h>
#include <rpc/server.h>
#include <rpc/util.h>
#include <script/script.h>
#include <shutdown.h>
#include <txmempool.h>
#include <univalue.h>
#include <util/fees.h>
#include <util/strencodings.h>
#include <util/system.h>
@ -100,7 +101,7 @@ static UniValue getnetworkhashps(const JSONRPCRequest& request)
return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1);
}
UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
static UniValue generateBlocks(const CScript& coinbase_script, int nGenerate, uint64_t nMaxTries)
{
static const int nInnerLoopCount = 0x10000;
int nHeightEnd = 0;
@ -115,7 +116,7 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
UniValue blockHashes(UniValue::VARR);
while (nHeight < nHeightEnd && !ShutdownRequested())
{
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(coinbaseScript->reserveScript));
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(coinbase_script));
if (!pblocktemplate.get())
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
CBlock *pblock = &pblocktemplate->block;
@ -138,12 +139,6 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
++nHeight;
blockHashes.push_back(pblock->GetHash().GetHex());
//mark script as important because it was used at least for one coinbase output if the script came from the wallet
if (keepScript)
{
coinbaseScript->KeepScript();
}
}
return blockHashes;
}
@ -181,10 +176,9 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
}
std::shared_ptr<CReserveScript> coinbaseScript = std::make_shared<CReserveScript>();
coinbaseScript->reserveScript = GetScriptForDestination(destination);
CScript coinbase_script = GetScriptForDestination(destination);
return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false);
return generateBlocks(coinbase_script, nGenerate, nMaxTries);
}
static UniValue getmininginfo(const JSONRPCRequest& request)

View file

@ -1,15 +0,0 @@
// Copyright (c) 2017 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_RPC_MINING_H
#define BITCOIN_RPC_MINING_H
#include <script/script.h>
#include <univalue.h>
/** Generate blocks (mine) */
UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript);
#endif

View file

@ -581,13 +581,4 @@ struct CScriptWitness
std::string ToString() const;
};
class CReserveScript
{
public:
CScript reserveScript;
virtual void KeepScript() {}
CReserveScript() {}
virtual ~CReserveScript() {}
};
#endif // BITCOIN_SCRIPT_SCRIPT_H

View file

@ -18,7 +18,6 @@ class CBlockIndex;
struct CBlockLocator;
class CBlockIndex;
class CConnman;
class CReserveScript;
class CValidationInterface;
class CValidationState;
class uint256;

View file

@ -1219,7 +1219,7 @@ public:
void MaybeResendWalletTxs();
/** A key allocated from the key pool. */
class CReserveKey final : public CReserveScript
class CReserveKey
{
protected:
CWallet* pwallet;
@ -1244,7 +1244,6 @@ public:
void ReturnKey();
bool GetReservedKey(CPubKey &pubkey, bool internal = false);
void KeepKey();
void KeepScript() override { KeepKey(); }
};
/** RAII object to check and reserve a wallet rescan */