Call FinalizeBlockAndInvalidate without cs_main held
Summary:
Now InvalidateBlock needs cs_main to be unlocked.
Related to the latest comments on D4758.
Depends on D4802
Test Plan:
- Build with Clang in Debug mode:
CXX=clang++ CC=clang cmake .. -D CMAKE_CXX_FLAGS="-Werror=thread-safety-analysis" -GNinja -DCMAKE_BUILD_TYPE=Debug ninja check-all
- Verify that the compiler has not emitted a thread-safety warning.
- Run the node: ./src/bitcoind -regtest
- Verify that text similar to "Assertion failed: lock ... not held ..." is not printed on stderr.
Reviewers: #bitcoin_abc, deadalnix, markblundeberg, jasonbcox
Reviewed By: #bitcoin_abc, jasonbcox
Subscribers: jasonbcox
Differential Revision: https://reviews.bitcoinabc.org/D4942