refactor: header class - remove caches and validation struct#148
Draft
fpelliccioni wants to merge 1 commit intomasterfrom
Draft
refactor: header class - remove caches and validation struct#148fpelliccioni wants to merge 1 commit intomasterfrom
fpelliccioni wants to merge 1 commit intomasterfrom
Conversation
f64dbdc to
95de25a
Compare
…uct (WIP) This PR refactors the `header` class to remove: - Mutable caches (hash, serialized size) - The `validation` struct (containing `height` and `median_time_past`) - Created two new header implementations for benchmarking: - `header_raw`: 80-byte array storage with on-demand field extraction - `header_members`: Individual member storage (current approach) - Removed `hash_memoizer` and caching mechanisms - Header is now a simple value type without mutable state - `fast_chain::insert()` and `block_chain::insert()` now take `median_time_past` as parameter - `reservations::import()` propagates MTP through the call chain - Added MTP calculation functions using C++20 concepts in `header.hpp` The `block_pool` class relies on `header().validation.height` which no longer exists. This affects: - `block_pool::add()` - needs height to insert blocks - `block_pool::remove()` - needs height to replant orphaned children as roots - `block_pool::prune()` - needs height to determine expired blocks 1. Pass height as parameter to `add()` 2. Store height in `block_entry` 3. Use `block::validation.state->height()` (chain_state already has height) 4. Calculate height by traversing parent chain Similar refactoring will be needed for `block` and `transaction` classes.
95de25a to
9695ca5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the
headerclass to remove mutable caches and thevalidationstruct.Changes
header_rawandheader_members)hash_memoizerand caching mechanismsinsert()signatures to passmedian_time_pastas parameterKnown Issues (WIP)
block_pool.cppcompilation errors: The class relies onheader().validation.heightwhich no longer exists. Possible solutions:add()block_entryblock::validation.state->height()Similar refactoring will be needed for
blockandtransactionclasses.Test plan
block_poolcompilation errors