rpc: Tidy up local references (see commit message)
Summary:
Organize local variables/references such that:
- There is always a ChainstateManager reference before any LOCK(cs_main).
- NodeContext references are used with Ensure*() functions introduced in previous commit where appropriate to avoid duplicate assertions.
This is a backport of core#21391 [12/14]
https://github.com/bitcoin/bitcoin/pull/21391/commits/6a3d1920209cded0dae52fb9070a3530d9a4e5fd
Depends on D11586
Test Plan:
With clang and debug:
ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D11587