HomePhabricator

mempool, validation: Explain cs_main locking semantics

Authored by MarcoFalke <falke.marco@gmail.com> on Dec 14 2018, 21:28.

Description

mempool, validation: Explain cs_main locking semantics

Summary:
Both the chain state and the transaction pool are validation specific, but access to them is protected by two locks. The two locks have the following semantics:

Backport of Bitcoin Core PR14963
https://github.com/bitcoin/bitcoin/pull/14963

Test Plan:

  1. Build with Clang in Debug mode:
CXX=clang++ CC=clang cmake .. -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.
  1. Run benchmarks:
cmake .. -GNinja
ninja bench-bitcoin
./src/bench/bitcoin-bench

Reviewers: Fabien, #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D4227

Details