Skip to content

Commit 7cc4e36

Browse files
committed
Added Some Comments for Clarity
1 parent 329b864 commit 7cc4e36

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

beacon_node/beacon_chain/src/beacon_block_streamer.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,26 @@ impl<T: BeaconChainTypes> BeaconBlockStreamer<T> {
524524
db_blocks
525525
}
526526

527-
// Pre-process the loaded blocks into execution engine requests, preserving the order of the blocks.
527+
/// Pre-process the loaded blocks into execution engine requests.
528+
///
529+
/// The purpose of this function is to separate the blocks into 3 categories:
530+
/// 1) no_request - when we already have the full block or there's an error
531+
/// 2) blocks_by_range - used for finalized blinded blocks
532+
/// 3) blocks_by_root - used for unfinalized blinded blocks
533+
///
534+
/// The function returns a mapping of (block_root -> request) as well as a vector
535+
/// of block roots so that we can return the blocks in the same order they were
536+
/// requested
528537
async fn get_requests(
529538
&self,
530539
payloads: Vec<(Hash256, LoadResult<T::EthSpec>)>,
531540
) -> (Vec<Hash256>, HashMap<Hash256, EngineRequest<T::EthSpec>>) {
532541
let mut ordered_block_roots = Vec::new();
533542
let mut requests = HashMap::new();
534543

535-
// separate off the by_range blocks so they can be sorted and then processed
544+
// we sort the by range blocks by slot before adding them to the
545+
// request as it should *better* optimize the number of blocks that
546+
// can fit in the same request
536547
let mut by_range_blocks: Vec<BlockParts<T::EthSpec>> = vec![];
537548
let mut by_hash = EngineRequest::new_by_hash();
538549
let mut no_request = EngineRequest::new_no_request();

0 commit comments

Comments
 (0)