Page MenuHomePhabricator

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

Authored by PiRK on Jun 8 2022, 15:32.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC0aa5c2bddb00: 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

Event Timeline

PiRK requested review of this revision.Jun 8 2022, 15:32
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/rpc/blockchain.cpp
1654 ↗(On Diff #33898)

Same as the other diff, this doesn't need the lock

This revision is now accepted and ready to land.Jun 9 2022, 15:16