mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
Remove nHeightEnd and nHeight in generateBlocks helper
This commit is contained in:
parent
fa38b1c8bd
commit
cccc4e879a
@ -145,17 +145,8 @@ static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t&
|
|||||||
|
|
||||||
static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& mempool, const CScript& coinbase_script, int nGenerate, uint64_t nMaxTries)
|
static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& mempool, const CScript& coinbase_script, int nGenerate, uint64_t nMaxTries)
|
||||||
{
|
{
|
||||||
int nHeightEnd = 0;
|
|
||||||
int nHeight = 0;
|
|
||||||
|
|
||||||
{ // Don't keep cs_main locked
|
|
||||||
LOCK(cs_main);
|
|
||||||
nHeight = chainman.ActiveChain().Height();
|
|
||||||
nHeightEnd = nHeight+nGenerate;
|
|
||||||
}
|
|
||||||
UniValue blockHashes(UniValue::VARR);
|
UniValue blockHashes(UniValue::VARR);
|
||||||
while (nHeight < nHeightEnd && !ShutdownRequested())
|
while (nGenerate > 0 && !ShutdownRequested()) {
|
||||||
{
|
|
||||||
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(chainman.ActiveChainstate(), mempool, Params()).CreateNewBlock(coinbase_script));
|
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(chainman.ActiveChainstate(), mempool, 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");
|
||||||
@ -167,7 +158,7 @@ static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& me
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!block_hash.IsNull()) {
|
if (!block_hash.IsNull()) {
|
||||||
++nHeight;
|
--nGenerate;
|
||||||
blockHashes.push_back(block_hash.GetHex());
|
blockHashes.push_back(block_hash.GetHex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user