Load block roots from fork choice where possible when serving BlocksByRange requests (#7058)

* Load block roots from fork choice where possible to avoid loading state from disk when serving block by range requests.

* Check if the start slot is newer than finalization (`start_slot >= finalized_slot`), and use fork choice in that case.
This commit is contained in:
Jimmy Chen
2025-03-01 08:41:24 +11:00
committed by GitHub
parent 9f15f31942
commit 8706040094
3 changed files with 160 additions and 197 deletions

View File

@@ -856,10 +856,18 @@ impl ProtoArrayForkChoice {
}
/// See `ProtoArray::iter_nodes`
pub fn iter_nodes<'a>(&'a self, block_root: &Hash256) -> Iter<'a> {
pub fn iter_nodes(&self, block_root: &Hash256) -> Iter {
self.proto_array.iter_nodes(block_root)
}
/// See `ProtoArray::iter_block_roots`
pub fn iter_block_roots(
&self,
block_root: &Hash256,
) -> impl Iterator<Item = (Hash256, Slot)> + use<'_> {
self.proto_array.iter_block_roots(block_root)
}
pub fn as_bytes(&self) -> Vec<u8> {
SszContainer::from(self).as_ssz_bytes()
}