pub async fn blocks(
        &self,
        first: Option<i32>,
        last: Option<i32>,
        before: Option<IndexCursor>,
        after: Option<IndexCursor>,
        context: &Context,
    ) -> FieldResult<Option<BlockConnection>> {
        let epoch_data = match self.get_epoch_data(&context.db).await {
            Some(epoch_data) => epoch_data,
            None => return Ok(None),
        };

        let epoch_lower_bound = context
            .db
            .get_block(&epoch_data.first_block)
            .await
            .map(|block| u32::from(block.chain_length))
            .expect("Epoch lower bound");

        let epoch_upper_bound = context
            .db
            .get_block(&epoch_data.last_block)
            .await
            .map(|block| u32::from(block.chain_length))
            .expect("Epoch upper bound");

        let boundaries = PaginationInterval::Inclusive(InclusivePaginationInterval {
            lower_bound: 0,
            upper_bound: epoch_upper_bound
                .checked_sub(epoch_lower_bound)
                .expect("pagination upper_bound to be greater or equal than lower_bound"),
        });

        let pagination_arguments = PaginationArguments {
            first,
            last,
            before: before.map(u32::try_from).transpose()?,
            after: after.map(u32::try_from).transpose()?,
        }
        .validate()?;

        BlockConnection::new_async(boundaries, pagination_arguments, |range| async {
            match range {
                PaginationInterval::Empty => unreachable!("No blocks found (not even genesis)"),
                PaginationInterval::Inclusive(range) => context
                    .db
                    .get_block_hash_range(
                        (range.lower_bound + epoch_lower_bound).into(),
                        (range.upper_bound + epoch_lower_bound + 1).into(),
                    )
                    .await
                    .iter()
                    .map(|(hash, index)| (*hash, u32::from(*index) - epoch_lower_bound))
                    .collect(),
            }
        })
        .await
        .map(Some)
    }
/// Get a paginated view of all the blocks in this epoch
Get a paginated view of all the blocks in this epoch
Get a paginated view of all the blocks in this epoch
pub async fn blocks(
        &self,
        first: Option<i32>,
        last: Option<i32>,
        before: Option<IndexCursor>,
        after: Option<IndexCursor>,
        context: &Context,
    ) -> FieldResult<Option<BlockConnection>> {
        let epoch_data = match self.get_epoch_data(&context.db).await {
            Some(epoch_data) => epoch_data,
            None => return Ok(None),
        };
        let epoch_lower_bound = context
            .db
            .get_block(&epoch_data.first_block)
            .await
            .map(|block| u32::from(block.chain_length))
            .expect("Epoch lower bound");
        let epoch_upper_bound = context
            .db
            .get_block(&epoch_data.last_block)
            .await
            .map(|block| u32::from(block.chain_length))
            .expect("Epoch upper bound");
        let boundaries = PaginationInterval::Inclusive(InclusivePaginationInterval {
            lower_bound: 0,
            upper_bound: epoch_upper_bound
                .checked_sub(epoch_lower_bound)
                .expect("pagination upper_bound to be greater or equal than lower_bound"),
        });
        let pagination_arguments = PaginationArguments {
            first,
            last,
            before: before.map(u32::try_from).transpose()?,
            after: after.map(u32::try_from).transpose()?,
        }
        .validate()?;
        BlockConnection::new_async(boundaries, pagination_arguments, |range| async {
            match range {
                PaginationInterval::Empty => unreachable!("No blocks found (not even genesis)"),
                PaginationInterval::Inclusive(range) => context
                    .db
                    .get_block_hash_range(
                        (range.lower_bound + epoch_lower_bound).into(),
                        (range.upper_bound + epoch_lower_bound + 1).into(),
                    )
                    .await
                    .iter()
                    .map(|(hash, index)| (*hash, u32::from(*index) - epoch_lower_bound))
                    .collect(),
            }
        })
        .await
        .map(Some)
    }
pub async fn blocks ( & self , first : Option < i32 > , last : Option < i32 > , before : Option < IndexCursor > , after : Option < IndexCursor > , context : & Context , ) -> FieldResult < Option < BlockConnection > > { let epoch_data = match self . get_epoch_data ( & context . db ) . await { Some ( epoch_data ) => epoch_data , None => return Ok ( None ) , } ; let epoch_lower_bound = context . db . get_block ( & epoch_data . first_block ) . await . map ( | block | u32 :: from ( block . chain_length ) ) . expect ( " " ) ; let epoch_upper_bound = context . db . get_block ( & epoch_data . last_block ) . await . map ( | block | u32 :: from ( block . chain_length ) ) . expect ( " " ) ; let boundaries = PaginationInterval :: Inclusive ( InclusivePaginationInterval { lower_bound : 0 , upper_bound : epoch_upper_bound . checked_sub ( epoch_lower_bound ) . expect ( " " ) , } ) ; let pagination_arguments = PaginationArguments { first , last , before : before . map ( u32 :: try_from ) . transpose ( ) ? , after : after . map ( u32 :: try_from ) . transpose ( ) ? , } . validate ( ) ? ; BlockConnection :: new_async ( boundaries , pagination_arguments , | range | async { match range { PaginationInterval :: Empty => unreachable ! ( " " ) , PaginationInterval :: Inclusive ( range ) => context . db . get_block_hash_range ( ( range . lower_bound + epoch_lower_bound ) . into ( ) , ( range . upper_bound + epoch_lower_bound + 1 ) . into ( ) , ) . await . iter ( ) . map ( | ( hash , index ) | ( * hash , u32 :: from ( * index ) - epoch_lower_bound ) ) . collect ( ) , } } ) . await . map ( Some ) }
Get a paginated view of all the blocks in this epoch
Get a paginated view of all the blocks in this epoch
&self
first
Option<i32>
last
Option<i32>
before
Option<IndexCursor>
after
Option<IndexCursor>
context
&Context
&self
first
Option<i32>
last
Option<i32>
before
Option<IndexCursor>
after
Option<IndexCursor>
context
&Context