(ctx context.Context, req *evm.QueryBlocksRequest, fromBlock, toBlock uint64, onPage func(proto.Message) error)
| 15 | ) |
| 16 | |
| 17 | func (qe *EvmQueryExecutor) shimQueryBlocks(ctx context.Context, req *evm.QueryBlocksRequest, fromBlock, toBlock uint64, onPage func(proto.Message) error) error { |
| 18 | _, shimSpan := common.StartDetailSpan(ctx, "Query.ShimBlocks") |
| 19 | defer shimSpan.End() |
| 20 | |
| 21 | order := req.GetOrder() |
| 22 | limit := queryLimit(req.GetLimit()) |
| 23 | qe.logger.Debug().Uint64("fromBlock", fromBlock).Uint64("toBlock", toBlock).Uint32("limit", limit).Msgf("starting shimQueryBlocks") |
| 24 | |
| 25 | blocks := make([]*evm.BlockHeader, 0, limit) |
| 26 | var last *evm.BlockHeader |
| 27 | var cursor *evm.CursorBlock |
| 28 | iter := newBlockIterator(fromBlock, toBlock, order) |
| 29 | for iter.Next() { |
| 30 | header, _, err := qe.fetchBlockViaForward(ctx, iter.Value(), false) |
| 31 | if err != nil { |
| 32 | return err |
| 33 | } |
| 34 | if header == nil { |
| 35 | continue |
| 36 | } |
| 37 | last = header |
| 38 | blocks = append(blocks, projectBlockForResponse(header, req.BlockFields)) |
| 39 | if len(blocks) >= int(limit) { |
| 40 | if iter.HasMore() { |
| 41 | cursor = cursorFromBlock(last) |
| 42 | } |
| 43 | break |
| 44 | } |
| 45 | } |
| 46 | return onPage(&evm.QueryBlocksResponse{ |
| 47 | Blocks: blocks, |
| 48 | FromBlock: cursorFromNumber(fromBlock), |
| 49 | ToBlock: cursorFromNumber(toBlock), |
| 50 | CursorBlock: cursor, |
| 51 | }) |
| 52 | } |
| 53 | |
| 54 | func (qe *EvmQueryExecutor) shimQueryTransactions(ctx context.Context, req *evm.QueryTransactionsRequest, fromBlock, toBlock uint64, onPage func(proto.Message) error) error { |
| 55 | _, shimSpan := common.StartDetailSpan(ctx, "Query.ShimTransactions") |
no test coverage detected