-
Notifications
You must be signed in to change notification settings - Fork 627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: De-duplicate code to create BlockHeader for genesis and view #12109
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12109 +/- ##
==========================================
+ Coverage 71.69% 71.74% +0.04%
==========================================
Files 825 825
Lines 165834 165697 -137
Branches 165834 165697 -137
==========================================
- Hits 118902 118884 -18
+ Misses 41751 41635 -116
+ Partials 5181 5178 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thank you!
} | ||
|
||
/// Common logic for generating BlockHeader for different purposes, including new blocks, from views, and for genesis block | ||
fn new_impl( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably unite arguments in BlockHeaderInnerLite, BlockHeaderInnerRestV1 (?) and the rest earlier to reduce number of arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to reduce the number of arguments (it is way too many now), but not sure how to do that at this point, let me submit this and I will reconsider that in a new PR.
We address a TODO item to use
BlockHeader::new
when creating aBlockHeader
in two other places (today these places use similar logic to choose the rightBlockHeader
version and contruct the inner structs based on the protocol version).BlockHeader
fromBlockHeaderView
.BlockHeader
for the genesis block.For this, we add
BlockHeader::new_impl
to contain the common code and have two other wrapper functions to callnew_impl
for the use cases above:BlockHeader::from_view
andBlockHeader::genesis
.