/// The transactions contained in the block
The transactions contained in the block
The transactions contained in the block
pub async fn transactions(
        &self,
        first: Option<i32>,
        last: Option<i32>,
        before: Option<IndexCursor>,
        after: Option<IndexCursor>,
        context: &Context,
    ) -> FieldResult<TransactionConnection> {
        let explorer_block = self.get_explorer_block(&context.db).await?;
        let mut transactions: Vec<&ExplorerTransaction> =
            explorer_block.transactions.values().collect();
        // TODO: This may be expensive at some point, but I can't rely in
        // the HashMap's order (also, I'm assuming the order in the block matters)
        transactions
            .as_mut_slice()
            .sort_unstable_by_key(|tx| tx.offset_in_block);
        let pagination_arguments = PaginationArguments {
            first,
            last,
            before: before.map(u32::try_from).transpose()?,
            after: after.map(u32::try_from).transpose()?,
        }
        .validate()?;
        let boundaries = if !transactions.is_empty() {
            PaginationInterval::Inclusive(InclusivePaginationInterval {
                lower_bound: 0u32,
                upper_bound: transactions
                    .len()
                    .checked_sub(1)
                    .unwrap()
                    .try_into()
                    .expect("tried to paginate more than 2^32 elements"),
            })
        } else {
            PaginationInterval::Empty
        };
        TransactionConnection::new(
            boundaries,
            pagination_arguments,
            |range: PaginationInterval<u32>| match range {
                PaginationInterval::Empty => vec![],
                PaginationInterval::Inclusive(range) => {
                    let from = usize::try_from(range.lower_bound).unwrap();
                    let to = usize::try_from(range.upper_bound).unwrap();
                    (from..=to)
                        .map(|i| {
                            (
                                TransactionNodeFetchInfo::Contents(transactions[i].clone()),
                                i.try_into().unwrap(),
                            )
                        })
                        .collect::<Vec<(TransactionNodeFetchInfo, u32)>>()
                }
            },
        )
    }
pub async fn transactions ( & self , first : Option < i32 > , last : Option < i32 > , before : Option < IndexCursor > , after : Option < IndexCursor > , context : & Context , ) -> FieldResult < TransactionConnection > { let explorer_block = self . get_explorer_block ( & context . db ) . await ? ; let mut transactions : Vec < & ExplorerTransaction > = explorer_block . transactions . values ( ) . collect ( ) ; // TODO: This may be expensive at some point, but I can't rely in // the HashMap's order (also, I'm assuming the order in the block matters) transactions . as_mut_slice ( ) . sort_unstable_by_key ( | tx | tx . offset_in_block ) ; let pagination_arguments = PaginationArguments { first , last , before : before . map ( u32 :: try_from ) . transpose ( ) ? , after : after . map ( u32 :: try_from ) . transpose ( ) ? , } . validate ( ) ? ; let boundaries = if ! transactions . is_empty ( ) { PaginationInterval :: Inclusive ( InclusivePaginationInterval { lower_bound : 0u32 , upper_bound : transactions . len ( ) . checked_sub ( 1 ) . unwrap ( ) . try_into ( ) . expect ( " " ) , } ) } else { PaginationInterval :: Empty } ; TransactionConnection :: new ( boundaries , pagination_arguments , | range : PaginationInterval < u32 > | match range { PaginationInterval :: Empty => vec ! [ ] , PaginationInterval :: Inclusive ( range ) => { let from = usize :: try_from ( range . lower_bound ) . unwrap ( ) ; let to = usize :: try_from ( range . upper_bound ) . unwrap ( ) ; ( from ..= to ) . map ( | i | { ( TransactionNodeFetchInfo :: Contents ( transactions [ i ] . clone ( ) ) , i . try_into ( ) . unwrap ( ) , ) } ) . collect :: < Vec < ( TransactionNodeFetchInfo , u32 ) > > ( ) } } , ) }
The transactions contained in the block
The transactions contained in the block
&self
first
Option<i32>
last
Option<i32>
before
Option<IndexCursor>
after
Option<IndexCursor>
context
&Context