Skip to content

Conversation

@doocho
Copy link

@doocho doocho commented Dec 29, 2025

Add index_for_key method to Archive trait and get_height to Blocks trait for retrieving block height from commitment without deserializing the full block.
Note : Optimization applies to prunable archive only. Immutable archive falls back to full block fetch.

Add a new method to efficiently retrieve the index (height) for a given
key without fetching the full value. This optimizes the case where only
the height is needed from a block commitment.

Changes:
- storage: Add index_for_key method to Archive trait
- storage: Implement optimized version for prunable::Archive using
  in-memory keys map
- storage: Add fallback (returns None) for immutable::Archive due to
  structural limitations
- consensus: Add get_height method to Blocks trait
- consensus: Use get_height in Actor to resolve TODO at line 345

The prunable::Archive can now return the index directly from its
in-memory mapping, avoiding the need to deserialize the full block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant