mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
setgenerate creates multiple blocks in -regtest mode
I'm writing some wallet regression tests using -regtest mode, and need to generate an initial multi-hundred-block chain. Repeatedly calling setgenerate to generate one block is slow and doesn't work properly, because block creation happens asynchronously. This adds two features to setgenerate in -regtest mode: 1) Instead of being interpreted as number of threads to start, the third argument is the number of blocks to generate. 2) setgenerate will not return until the block creation threads have created the requested number of blocks.
This commit is contained in:
@@ -650,11 +650,10 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateBitcoins(bool fGenerate, CWallet* pwallet)
|
||||
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
|
||||
{
|
||||
static boost::thread_group* minerThreads = NULL;
|
||||
|
||||
int nThreads = GetArg("-genproclimit", -1);
|
||||
if (nThreads < 0) {
|
||||
if (Params().NetworkID() == CChainParams::REGTEST)
|
||||
nThreads = 1;
|
||||
|
||||
Reference in New Issue
Block a user