mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Remove buggy and confusing IncrementExtraNonce
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <chainparams.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>
|
||||
@@ -43,7 +44,6 @@
|
||||
|
||||
using node::BlockAssembler;
|
||||
using node::CBlockTemplate;
|
||||
using node::IncrementExtraNonce;
|
||||
using node::NodeContext;
|
||||
using node::RegenerateCommitments;
|
||||
using node::UpdateTime;
|
||||
@@ -116,14 +116,10 @@ static RPCHelpMan getnetworkhashps()
|
||||
};
|
||||
}
|
||||
|
||||
static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t& max_tries, unsigned int& extra_nonce, uint256& block_hash)
|
||||
static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t& max_tries, uint256& block_hash)
|
||||
{
|
||||
block_hash.SetNull();
|
||||
|
||||
{
|
||||
LOCK(cs_main);
|
||||
IncrementExtraNonce(&block, chainman.ActiveChain().Tip(), extra_nonce);
|
||||
}
|
||||
block.hashMerkleRoot = BlockMerkleRoot(block);
|
||||
|
||||
CChainParams chainparams(Params());
|
||||
|
||||
@@ -157,7 +153,6 @@ static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& me
|
||||
nHeight = chainman.ActiveChain().Height();
|
||||
nHeightEnd = nHeight+nGenerate;
|
||||
}
|
||||
unsigned int nExtraNonce = 0;
|
||||
UniValue blockHashes(UniValue::VARR);
|
||||
while (nHeight < nHeightEnd && !ShutdownRequested())
|
||||
{
|
||||
@@ -167,7 +162,7 @@ static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& me
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
|
||||
uint256 block_hash;
|
||||
if (!GenerateBlock(chainman, *pblock, nMaxTries, nExtraNonce, block_hash)) {
|
||||
if (!GenerateBlock(chainman, *pblock, nMaxTries, block_hash)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -397,9 +392,8 @@ static RPCHelpMan generateblock()
|
||||
|
||||
uint256 block_hash;
|
||||
uint64_t max_tries{DEFAULT_MAX_TRIES};
|
||||
unsigned int extra_nonce{0};
|
||||
|
||||
if (!GenerateBlock(chainman, block, max_tries, extra_nonce, block_hash) || block_hash.IsNull()) {
|
||||
if (!GenerateBlock(chainman, block, max_tries, block_hash) || block_hash.IsNull()) {
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "Failed to make block.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user