Call FinalizeBlockAndInvalidate without cs_main held

Authored by fpelliccioni on Jan 14 2020, 16:08.


Call FinalizeBlockAndInvalidate without cs_main held

Now InvalidateBlock needs cs_main to be unlocked.
Related to the latest comments on D4758.

Depends on D4802

Test Plan:

  1. 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
  1. Verify that the compiler has not emitted a thread-safety warning.
  2. Run the node: ./src/bitcoind -regtest
  3. 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