Optimize -regtest setgenerate block generation

Speed up generating blocks in regression test mode, by moving
block-creating and nonce-finding directly into the setgenerate
RPC call (instead of starting up a mining thread and waiting for
it to find a block).

This makes the forknotify RPC test three times quicker, for
example (10 seconds runtime instead of 30 seconds, assuming
the initial blockchain cache is already built).
Merge pull request #5275

1837987 Optimize -regtest setgenerate block generation (Gavin Andresen)

Signed-off-by: Gavin Andresen <gavinandresen@gmail.com>