reworks update_completed_data_indexes when inserting shreds #4531
+81
−87
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.
Problem
blockstore::update_completed_data_indexes
https://github.com/anza-xyz/agave/blob/0f56076a2/ledger/src/blockstore.rs#L4722-L4758
can be implemented more idiomatically and avoid several allocations in the process by just holding onto iterators:
https://github.com/anza-xyz/agave/blob/0f56076a2/ledger/src/blockstore.rs#L4739
https://github.com/anza-xyz/agave/blob/0f56076a2/ledger/src/blockstore.rs#L4757
https://github.com/anza-xyz/agave/blob/0f56076a2/ledger/src/blockstore.rs#L2254
Additionally we can utilize
Range<u32>
instead of(u32, u32)
tuples which are ambiguous if they are inclusive or not:https://github.com/anza-xyz/agave/blob/0f56076a2/ledger/src/blockstore.rs#L4731
https://github.com/anza-xyz/agave/blob/0f56076a2/ledger/src/blockstore.rs#L4768
https://github.com/anza-xyz/agave/blob/0f56076a2/ledger/src/blockstore.rs#L216-L222
Summary of Changes
The commit simplifies
update_completed_data_indexes
implementation, removes multiple intermediate allocations and usesRange<u32>
instead of(u32, u32)
tuples.