net: reduce LOCK(cs_main) scope in GETBLOCKTXN
Summary:
Also adds a static assertion that MAX_BLOCKTXN_DEPTH <= MIN_BLOCKS_TO_KEEP
from the PR description:
Inspired by core#26308
(backported in D13052 -- D13057)
This is a partial backport of core#26326
https://github.com/bitcoin/bitcoin/pull/26326/commits/613a45cd4b5482aedbdc7c61c839ea05996935c6
Test Plan:
With Debug:
ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D18255