rpc/rest: Take and reuse local Chain/ChainState obj
Summary:
In all rest/rpc-related modules, if there are multiple calls to
ActiveChain{,State}(), and the calls fall under the same ::cs_main lock,
we can simply take a local reference and use/reuse it instead of calling
ActiveChain{,State}() again and again.
This concludes backport of core#21391 [14/14]
https://github.com/bitcoin/bitcoin/pull/21391/commits/586190f0b4740457cb86cba632e3d64e6dfe9b0c
Depends on D11588
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D11589