Skip to content

Commit cccc4e8

Browse files
author
MarcoFalke
committed
Remove nHeightEnd and nHeight in generateBlocks helper
1 parent fa38b1c commit cccc4e8

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/rpc/mining.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,8 @@ static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t&
145145

146146
static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& mempool, const CScript& coinbase_script, int nGenerate, uint64_t nMaxTries)
147147
{
148-
int nHeightEnd = 0;
149-
int nHeight = 0;
150-
151-
{ // Don't keep cs_main locked
152-
LOCK(cs_main);
153-
nHeight = chainman.ActiveChain().Height();
154-
nHeightEnd = nHeight+nGenerate;
155-
}
156148
UniValue blockHashes(UniValue::VARR);
157-
while (nHeight < nHeightEnd && !ShutdownRequested())
158-
{
149+
while (nGenerate > 0 && !ShutdownRequested()) {
159150
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(chainman.ActiveChainstate(), mempool, Params()).CreateNewBlock(coinbase_script));
160151
if (!pblocktemplate.get())
161152
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
@@ -167,7 +158,7 @@ static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& me
167158
}
168159

169160
if (!block_hash.IsNull()) {
170-
++nHeight;
161+
--nGenerate;
171162
blockHashes.push_back(block_hash.GetHex());
172163
}
173164
}

0 commit comments

Comments
 (0)