def _get_requested_beacon_blocks(self, beacon_blocks_request: BeaconBlocksRequest, requested_head_block: BaseBeaconBlock) -> Tuple[(BaseBeaconBlock, ...)]:
    slot_of_requested_blocks = tuple(((beacon_blocks_request.start_slot + (i * beacon_blocks_request.step)) for i in range(beacon_blocks_request.count)))
    self.logger.info('slot_of_requested_blocks: %s', slot_of_requested_blocks)
    slot_of_requested_blocks = tuple(filter((lambda slot: (slot <= requested_head_block.slot)), slot_of_requested_blocks))
    if (len(slot_of_requested_blocks) == 0):
        return tuple()
    try:
        canonical_block_at_slot = self.chain.get_canonical_block_by_slot(requested_head_block.slot)
        block_match = (canonical_block_at_slot == requested_head_block)
    except BlockNotFound:
        self.logger.debug('The requested head block is not on our canonical chain  requested_head_block: %s  canonical_block_at_slot: %s', requested_head_block, canonical_block_at_slot)
        block_match = False
    finally:
        if block_match:
            return self._get_blocks_from_canonical_chain_by_slot(slot_of_requested_blocks)
        else:
            self._validate_start_slot(beacon_blocks_request.start_slot)
            return self._get_blocks_from_fork_chain_by_root(beacon_blocks_request.start_slot, requested_head_block, slot_of_requested_blocks)
def _get_requested_beacon_blocks(self, beacon_blocks_request: BeaconBlocksRequest, requested_head_block: BaseBeaconBlock) -> Tuple[(BaseBeaconBlock, ...)]:
    slot_of_requested_blocks = tuple(((beacon_blocks_request.start_slot + (i * beacon_blocks_request.step)) for i in range(beacon_blocks_request.count)))
    self.logger.info('slot_of_requested_blocks: %s', slot_of_requested_blocks)
    slot_of_requested_blocks = tuple(filter((lambda slot: (slot <= requested_head_block.slot)), slot_of_requested_blocks))
    if (len(slot_of_requested_blocks) == 0):
        return tuple()
    try:
        canonical_block_at_slot = self.chain.get_canonical_block_by_slot(requested_head_block.slot)
        block_match = (canonical_block_at_slot == requested_head_block)
    except BlockNotFound:
        self.logger.debug('The requested head block is not on our canonical chain  requested_head_block: %s  canonical_block_at_slot: %s', requested_head_block, canonical_block_at_slot)
        block_match = False
    finally:
        if block_match:
            return self._get_blocks_from_canonical_chain_by_slot(slot_of_requested_blocks)
        else:
            self._validate_start_slot(beacon_blocks_request.start_slot)
            return self._get_blocks_from_fork_chain_by_root(beacon_blocks_request.start_slot, requested_head_block, slot_of_requested_blocks)