HomePhabricator

rpc/rest: Take and reuse local Chain/ChainState obj

Description

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

Details

Provenance
Carl Dong <contact@carldong.me>Authored on Apr 13 2021, 01:34
PiRKCommitted on Jun 9 2022, 16:19
PiRKPushed on Jun 9 2022, 16:19
Reviewer
Restricted Project
Differential Revision
D11589: rpc/rest: Take and reuse local Chain/ChainState obj
Parents
rABC3d100ae1b786: rpc: Remove unnecessary casting of block height
Branches
Unknown
Tags
Unknown