Simplify flat store, create get_header_by_height
#532
Merged
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.
What is the purpose of this pull request?
Which crates are being modified?
Description
I have added a new required method to
ChainStorethat allows fetching the header directly from the height, which is supported out of the box withFlatChainStore.I also made the flat store
Indeximpl be under its own module, enforcing we always use the API. Then I refactoredget_block_header_by_indexinto the innerget_disk_header, which is more concise. This also ensures our heights are checked to be 31-bits.EDIT:
save_roots_for_blocknow returns error if we don't have the respective header, which makes the behavior more consistent. (same for the load function)