rpc: Better way to allow shutdown while in generateblocks
Summary:
By checking the shutdown flag every loop we can use the entire nonce space
instead of breaking every 16 bits to check the shutdown flag.
This has been possible since the shutdown flag was switched to an atomic,
before that change it was controlled by a condition variable and lock.
Backport of Core PR16262
Test Plan:
ninja && ninja check-all
This still runs fine:
addr=`src/bitcoin-cli -regtest getnewaddress` bitcoin-cli -regtest generatetoaddress 100 $addr
This command can still be interrupted cleanly with Ctrl-C:
bitcoin-cli -regtest generatetoaddress 100000 $addr
Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien
Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D7839