Fix a data race that could prevent the staking reward to be added to the block template when longpoll is used
Summary:
This diff turns the best block global into a block index instead of a hash and performs a staking reward computation
upon longpoll interruption when building the block template. It avoids a data race where the template could be
constructed and returned before the computation of staking rewards is complete, leading to an empty winner and
potentially a rejected block.
Test Plan:
for i in {1..1000}; do echo "Trial $i/1000" && ./test/functional/test_runner.py abc_mining_stakingrewards || break; done
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Differential Revision: https://reviews.bitcoinabc.org/D16430