Page MenuHomePhabricator

Deduplicate some block-to-JSON code.
ClosedPublic

Authored by PiRK on Apr 12 2022, 13:32.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC184ba16e70b1: Deduplicate some block-to-JSON code.
Summary

Some of the logic converting blocks and block headers to JSON for
the blockchain RPC methods (getblock, getlockheader) was duplicated.
Instead of that, the blockToJSON RPC method now calls blockheaderToJSON
first, and then fills in the missing, block-specific bits explicitly.

This is a backport of core#21114

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.Apr 12 2022, 13:32
Fabien requested changes to this revision.Apr 12 2022, 20:20
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/rpc/blockchain.cpp
158

This is now duplicated

This revision now requires changes to proceed.Apr 12 2022, 20:20

remove duplicate result.pushKV("height", blockindex->nHeight);

This revision is now accepted and ready to land.Apr 13 2022, 08:28
This revision was automatically updated to reflect the committed changes.