Split the cs_main lock in SendMessages
Summary:
The PeerManager::SendMessages() method locks the cs_main for almost
the whole function. This diff splits the lock into pieces, slightly
reducing the scope and making it possible to later add avalanche parts
that don't lock cs_main.
Test Plan:
With clang and debug:
ninja all check-all ./test/functional/test_runner.py p2p_tx_download # extended
Run the TSAN build.
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D9558