diff options
author | MarcoFalke <falke.marco@gmail.com> | 2022-04-05 13:11:08 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2022-04-05 13:05:14 +0200 |
commit | cccc4e879a8cb9d858a88ea46b28ea27ab79ca55 (patch) | |
tree | 3acddeed912a63bab17ac458fae28d441824d351 /src/rpc/mining.cpp | |
parent | fa38b1c8bd29e2c792737f6481ab928e46396b7e (diff) |
Remove nHeightEnd and nHeight in generateBlocks helper
Diffstat (limited to 'src/rpc/mining.cpp')
-rw-r--r-- | src/rpc/mining.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 831d3c7783..211026c8d9 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -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) { - 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); - while (nHeight < nHeightEnd && !ShutdownRequested()) - { + while (nGenerate > 0 && !ShutdownRequested()) { std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(chainman.ActiveChainstate(), mempool, Params()).CreateNewBlock(coinbase_script)); if (!pblocktemplate.get()) 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()) { - ++nHeight; + --nGenerate; blockHashes.push_back(block_hash.GetHex()); } } |