Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | |||||
static bool GenerateBlock(const Config &config, ChainstateManager &chainman, | static bool GenerateBlock(const Config &config, ChainstateManager &chainman, | ||||
CBlock &block, uint64_t &max_tries, | CBlock &block, uint64_t &max_tries, | ||||
unsigned int &extra_nonce, BlockHash &block_hash) { | unsigned int &extra_nonce, BlockHash &block_hash) { | ||||
block_hash.SetNull(); | block_hash.SetNull(); | ||||
const uint64_t nExcessiveBlockSize = config.GetMaxBlockSize(); | const uint64_t nExcessiveBlockSize = config.GetMaxBlockSize(); | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CHECK_NONFATAL(std::addressof(::ChainActive()) == | |||||
std::addressof(chainman.ActiveChain())); | |||||
IncrementExtraNonce(&block, chainman.ActiveTip(), nExcessiveBlockSize, | IncrementExtraNonce(&block, chainman.ActiveTip(), nExcessiveBlockSize, | ||||
extra_nonce); | extra_nonce); | ||||
} | } | ||||
const Consensus::Params ¶ms = config.GetChainParams().GetConsensus(); | const Consensus::Params ¶ms = config.GetChainParams().GetConsensus(); | ||||
while (max_tries > 0 && | while (max_tries > 0 && | ||||
block.nNonce < std::numeric_limits<uint32_t>::max() && | block.nNonce < std::numeric_limits<uint32_t>::max() && | ||||
Show All 26 Lines | static UniValue generateBlocks(const Config &config, | ||||
const CScript &coinbase_script, int nGenerate, | const CScript &coinbase_script, int nGenerate, | ||||
uint64_t nMaxTries) { | uint64_t nMaxTries) { | ||||
int nHeightEnd = 0; | int nHeightEnd = 0; | ||||
int nHeight = 0; | int nHeight = 0; | ||||
{ | { | ||||
// Don't keep cs_main locked. | // Don't keep cs_main locked. | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CHECK_NONFATAL(std::addressof(::ChainActive()) == | |||||
std::addressof(chainman.ActiveChain())); | |||||
nHeight = chainman.ActiveHeight(); | nHeight = chainman.ActiveHeight(); | ||||
nHeightEnd = nHeight + nGenerate; | nHeightEnd = nHeight + nGenerate; | ||||
} | } | ||||
unsigned int nExtraNonce = 0; | unsigned int nExtraNonce = 0; | ||||
UniValue blockHashes(UniValue::VARR); | UniValue blockHashes(UniValue::VARR); | ||||
while (nHeight < nHeightEnd && !ShutdownRequested()) { | while (nHeight < nHeightEnd && !ShutdownRequested()) { | ||||
std::unique_ptr<CBlockTemplate> pblocktemplate( | std::unique_ptr<CBlockTemplate> pblocktemplate( | ||||
▲ Show 20 Lines • Show All 1,069 Lines • Show Last 20 Lines |