async def list_batches(self, request): """Fetches list of batches from validator, optionally filtered by id. Request: query: - head: The id of the block to use as the head of the chain - id: Comma separated list of batch ids to include in results Response: data: JSON array of fully expanded Batch objects head: The head used for this query (most recent if unspecified) link: The link to this exact query, including head block paging: Paging info and nav, like total resources and a next link """ paging_controls = self._get_paging_controls(request) validator_query = client_pb2.ClientBatchListRequest( head_id=request.url.query.get('head', None), batch_ids=self._get_filter_ids(request), paging=self._make_paging_message(paging_controls)) response = await self._query_validator( Message.CLIENT_BATCH_LIST_REQUEST, client_pb2.ClientBatchListResponse, validator_query) return self._wrap_paginated_response( request=request, response=response, controls=paging_controls, data=[self._expand_batch(b) for b in response['batches']])
def batch_list(self, request): """ Fetch a list of batches from the validator """ head = request.url.query.get('head', None) batch_ids = RouteHandler._get_filter_ids(request) response = self._query_validator( Message.CLIENT_BATCH_LIST_REQUEST, client.ClientBatchListResponse, client.ClientBatchListRequest(head_id=head, batch_ids=batch_ids)) batches = [RouteHandler._expand_batch(b) for b in response['batches']] return RouteHandler._wrap_response(data=batches, metadata=RouteHandler._get_metadata( request, response))