mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-23 15:20:49 +01:00
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: utACK1b46a4889f
meshcollider: utACK1b46a4889f
scravy: utACK1b46a48
Empact: utACK1b46a4889f
Tree-SHA512: d1fab1bf76ac3036b85cf33be89868bc016f912575545ecaa16f958397b0ec4f1ce4de8fe254d4f21aabeea9c83a8928530cc520de26af0d1a8bdb4ca0f2cb77
This commit is contained in:
commit
adc55dbac5
6 changed files with 7 additions and 40 deletions
|
@ -174,7 +174,6 @@ BITCOIN_CORE_H = \
|
||||||
reverselock.h \
|
reverselock.h \
|
||||||
rpc/blockchain.h \
|
rpc/blockchain.h \
|
||||||
rpc/client.h \
|
rpc/client.h \
|
||||||
rpc/mining.h \
|
|
||||||
rpc/protocol.h \
|
rpc/protocol.h \
|
||||||
rpc/server.h \
|
rpc/server.h \
|
||||||
rpc/rawtransaction_util.h \
|
rpc/rawtransaction_util.h \
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
#include <policy/fees.h>
|
#include <policy/fees.h>
|
||||||
#include <pow.h>
|
#include <pow.h>
|
||||||
#include <rpc/blockchain.h>
|
#include <rpc/blockchain.h>
|
||||||
#include <rpc/mining.h>
|
|
||||||
#include <rpc/server.h>
|
#include <rpc/server.h>
|
||||||
#include <rpc/util.h>
|
#include <rpc/util.h>
|
||||||
|
#include <script/script.h>
|
||||||
#include <shutdown.h>
|
#include <shutdown.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
|
#include <univalue.h>
|
||||||
#include <util/fees.h>
|
#include <util/fees.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/system.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);
|
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;
|
static const int nInnerLoopCount = 0x10000;
|
||||||
int nHeightEnd = 0;
|
int nHeightEnd = 0;
|
||||||
|
@ -115,7 +116,7 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
|
||||||
UniValue blockHashes(UniValue::VARR);
|
UniValue blockHashes(UniValue::VARR);
|
||||||
while (nHeight < nHeightEnd && !ShutdownRequested())
|
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())
|
if (!pblocktemplate.get())
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
|
||||||
CBlock *pblock = &pblocktemplate->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");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
|
||||||
++nHeight;
|
++nHeight;
|
||||||
blockHashes.push_back(pblock->GetHash().GetHex());
|
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;
|
return blockHashes;
|
||||||
}
|
}
|
||||||
|
@ -181,10 +176,9 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Error: Invalid address");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CReserveScript> coinbaseScript = std::make_shared<CReserveScript>();
|
CScript coinbase_script = GetScriptForDestination(destination);
|
||||||
coinbaseScript->reserveScript = GetScriptForDestination(destination);
|
|
||||||
|
|
||||||
return generateBlocks(coinbaseScript, nGenerate, nMaxTries, false);
|
return generateBlocks(coinbase_script, nGenerate, nMaxTries);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UniValue getmininginfo(const JSONRPCRequest& request)
|
static UniValue getmininginfo(const JSONRPCRequest& request)
|
||||||
|
|
|
@ -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
|
|
|
@ -581,13 +581,4 @@ struct CScriptWitness
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CReserveScript
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CScript reserveScript;
|
|
||||||
virtual void KeepScript() {}
|
|
||||||
CReserveScript() {}
|
|
||||||
virtual ~CReserveScript() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // BITCOIN_SCRIPT_SCRIPT_H
|
#endif // BITCOIN_SCRIPT_SCRIPT_H
|
||||||
|
|
|
@ -18,7 +18,6 @@ class CBlockIndex;
|
||||||
struct CBlockLocator;
|
struct CBlockLocator;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
class CReserveScript;
|
|
||||||
class CValidationInterface;
|
class CValidationInterface;
|
||||||
class CValidationState;
|
class CValidationState;
|
||||||
class uint256;
|
class uint256;
|
||||||
|
|
|
@ -1219,7 +1219,7 @@ public:
|
||||||
void MaybeResendWalletTxs();
|
void MaybeResendWalletTxs();
|
||||||
|
|
||||||
/** A key allocated from the key pool. */
|
/** A key allocated from the key pool. */
|
||||||
class CReserveKey final : public CReserveScript
|
class CReserveKey
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
CWallet* pwallet;
|
CWallet* pwallet;
|
||||||
|
@ -1244,7 +1244,6 @@ public:
|
||||||
void ReturnKey();
|
void ReturnKey();
|
||||||
bool GetReservedKey(CPubKey &pubkey, bool internal = false);
|
bool GetReservedKey(CPubKey &pubkey, bool internal = false);
|
||||||
void KeepKey();
|
void KeepKey();
|
||||||
void KeepScript() override { KeepKey(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** RAII object to check and reserve a wallet rescan */
|
/** RAII object to check and reserve a wallet rescan */
|
||||||
|
|
Loading…
Add table
Reference in a new issue