-
Notifications
You must be signed in to change notification settings - Fork 84
Introduce HeaderExtension to centralize header-related logic #722
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
Introduce HeaderExtension to centralize header-related logic #722
Conversation
jaoleal
left a comment
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.
Strong ACK.
Here some suggestion, nice idea @Davidson-Souza.
|
Extension traits usually have the suffix |
bb2d635 to
2e30e65
Compare
4bab62b to
42f37f3
Compare
42f37f3 to
ed26800
Compare
ed26800 to
96fd6b6
Compare
jaoleal
left a comment
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.
just more these and i think well be at the finals
3d84e46 to
88acd41
Compare
6503a07 to
f9821eb
Compare
f9821eb to
82e545c
Compare
jaoleal
left a comment
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.
Some suggestions
8e8d56a to
31bdd1d
Compare
|
@jaoleal I implemented your code suggestion, but I had to make some small changes because there were some errors in the chunking function you used, so I had to adjust that part. |
- Added methods for calculating median time past, chain work, and retrieving block details.
- Introduced HeaderExtension trait for improved header operations. - Updated GetBlockResVerbose to use f64 for difficulty and added target field. - Enhanced error handling in JsonRpcError for chain work calculations. - Updated tests to reflect changes in difficulty and chain work representation.
31bdd1d to
98b5219
Compare
|
ACK 98b5219 |
Davidson-Souza
left a comment
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.
ACK 98b5219
Description and Notes
Introduces
HeaderExtension, a trait that adds shared helper functions tobitcoin::Header. As suggested in PR #682 , the goal is to centralize logic that depends on block headers and is reused across different RPC methods. This includes calculations such as chain work, median time past, and other header-derived values.By consolidating this logic in a single place, we reduce duplication, ensure consistent behavior across RPC calls, and lower the chances of errors caused by incorrect variable handling.
How to verify the changes
Check the Floresta RPC outputs for
getblockchaininfoandgetblock. The returned fields must match the corresponding values from Bitcoin Core’s RPCs for the same blocks.