Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
mining.cpp File Reference
#include <bitcoin-build-config.h>
#include <chain.h>
#include <chainparams.h>
#include <chainparamsbase.h>
#include <common/system.h>
#include <consensus/amount.h>
#include <consensus/consensus.h>
#include <consensus/merkle.h>
#include <consensus/params.h>
#include <consensus/validation.h>
#include <core_io.h>
#include <deploymentinfo.h>
#include <deploymentstatus.h>
#include <interfaces/mining.h>
#include <key_io.h>
#include <net.h>
#include <node/context.h>
#include <node/miner.h>
#include <node/warnings.h>
#include <policy/ephemeral_policy.h>
#include <pow.h>
#include <rpc/blockchain.h>
#include <rpc/mining.h>
#include <rpc/server.h>
#include <rpc/server_util.h>
#include <rpc/util.h>
#include <script/descriptor.h>
#include <script/script.h>
#include <script/signingprovider.h>
#include <txmempool.h>
#include <univalue.h>
#include <util/signalinterrupt.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/time.h>
#include <util/translation.h>
#include <validation.h>
#include <validationinterface.h>
#include <cstdint>
#include <memory>
Include dependency graph for mining.cpp:

Go to the source code of this file.

Classes

class  submitblock_StateCatcher

Functions

static UniValue GetNetworkHashPS (int lookup, int height, const CChain &active_chain)
 Return average network hashes per second based on the last 'lookup' blocks, or from the last difficulty change if 'lookup' is -1.
static RPCHelpMan getnetworkhashps ()
static bool GenerateBlock (ChainstateManager &chainman, CBlock &&block, uint64_t &max_tries, std::shared_ptr< const CBlock > &block_out, bool process_new_block)
static UniValue generateBlocks (ChainstateManager &chainman, Mining &miner, const CScript &coinbase_output_script, int nGenerate, uint64_t nMaxTries)
static bool getScriptFromDescriptor (std::string_view descriptor, CScript &script, std::string &error)
static RPCHelpMan generatetodescriptor ()
static RPCHelpMan generate ()
static RPCHelpMan generatetoaddress ()
static RPCHelpMan generateblock ()
static RPCHelpMan getmininginfo ()
static RPCHelpMan prioritisetransaction ()
static RPCHelpMan getprioritisedtransactions ()
static UniValue BIP22ValidationResult (const BlockValidationState &state)
static std::string gbt_rule_value (const std::string &name, bool gbt_optional_rule)
static RPCHelpMan getblocktemplate ()
static RPCHelpMan submitblock ()
static RPCHelpMan submitheader ()
void RegisterMiningRPCCommands (CRPCTable &t)
int64_t GetMinimumTime (const CBlockIndex *pindexPrev, int64_t difficulty_adjustment_interval)
 Get the minimum time a miner should use in the next block.
void RegenerateCommitments (CBlock &block, ChainstateManager &chainman)
 Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed.
int64_t UpdateTime (CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
template<typename T>
std::string ToString (const T &t)
 Locale-independent version of std::to_string.

Function Documentation

◆ BIP22ValidationResult()

UniValue BIP22ValidationResult ( const BlockValidationState & state)
static

Definition at line 586 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gbt_rule_value()

std::string gbt_rule_value ( const std::string & name,
bool gbt_optional_rule )
static

Definition at line 605 of file mining.cpp.

Here is the caller graph for this function:

◆ generate()

RPCHelpMan generate ( )
static

Definition at line 257 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateBlock()

bool GenerateBlock ( ChainstateManager & chainman,
CBlock && block,
uint64_t & max_tries,
std::shared_ptr< const CBlock > & block_out,
bool process_new_block )
static

Definition at line 137 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateblock()

RPCHelpMan generateblock ( )
static

Definition at line 305 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateBlocks()

UniValue generateBlocks ( ChainstateManager & chainman,
Mining & miner,
const CScript & coinbase_output_script,
int nGenerate,
uint64_t nMaxTries )
static

Definition at line 164 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generatetoaddress()

RPCHelpMan generatetoaddress ( )
static

Definition at line 264 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generatetodescriptor()

RPCHelpMan generatetodescriptor ( )
static

Definition at line 219 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getblocktemplate()

RPCHelpMan getblocktemplate ( )
static

Wait to respond until either the best block changes, OR there are more transactions.

The check for new transactions first happens after 1 minute and subsequently every 10 seconds. BIP22 does not require this particular interval. On mainnet the mempool changes frequently enough that in practice this RPC returns after 60 seconds, or sooner if the best block changes.

getblocktemplate is unlikely to be called by bitcoin-cli, so -rpcclienttimeout is not a concern. BIP22 recommends a long request timeout.

The longpollid is assumed to be a tip hash if it has the right format.

Definition at line 614 of file mining.cpp.

Here is the caller graph for this function:

◆ GetMinimumTime()

int64_t node::GetMinimumTime ( const CBlockIndex * pindexPrev,
const int64_t difficulty_adjustment_interval )

Get the minimum time a miner should use in the next block.

This always accounts for the BIP94 timewarp rule, so does not necessarily reflect the consensus limit.

Definition at line 36 of file miner.cpp.

Here is the caller graph for this function:

◆ getmininginfo()

RPCHelpMan getmininginfo ( )
static

Definition at line 415 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNetworkHashPS()

UniValue GetNetworkHashPS ( int lookup,
int height,
const CChain & active_chain )
static

Return average network hashes per second based on the last 'lookup' blocks, or from the last difficulty change if 'lookup' is -1.

If 'height' is -1, compute the estimate from current chain tip. If 'height' is a valid block height, compute the estimate at the time when a given block was found.

Definition at line 65 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getnetworkhashps()

RPCHelpMan getnetworkhashps ( )
static

Definition at line 111 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getprioritisedtransactions()

RPCHelpMan getprioritisedtransactions ( )
static

Definition at line 546 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getScriptFromDescriptor()

bool getScriptFromDescriptor ( std::string_view descriptor,
CScript & script,
std::string & error )
static

Definition at line 184 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prioritisetransaction()

RPCHelpMan prioritisetransaction ( )
static

Definition at line 501 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegenerateCommitments()

void node::RegenerateCommitments ( CBlock & block,
ChainstateManager & chainman )

Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed.

Definition at line 67 of file miner.cpp.

Here is the caller graph for this function:

◆ RegisterMiningRPCCommands()

void RegisterMiningRPCCommands ( CRPCTable & t)

Definition at line 1141 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ submitblock()

RPCHelpMan submitblock ( )
static

Definition at line 1049 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ submitheader()

RPCHelpMan submitheader ( )
static

Definition at line 1101 of file mining.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToString()

template<typename T>
std::string util::ToString ( const T & t)

Locale-independent version of std::to_string.

Definition at line 246 of file string.h.

◆ UpdateTime()

int64_t node::UpdateTime ( CBlockHeader * pblock,
const Consensus::Params & consensusParams,
const CBlockIndex * pindexPrev )

Definition at line 49 of file miner.cpp.

Here is the caller graph for this function: