async def fetch_block(self, request): """Fetches a specific block from the validator, specified by id. Request: path: - block_id: The 128-character id of the block to be fetched Response: data: A JSON object with the data from the fully expanded Block link: The link to this exact query """ error_traps = [ error_handlers.MissingBlock(), error_handlers.InvalidBlockId() ] block_id = request.match_info.get('block_id', '') response = await self._query_validator( Message.CLIENT_BLOCK_GET_REQUEST, client_pb2.ClientBlockGetResponse, client_pb2.ClientBlockGetRequest(block_id=block_id), error_traps) return self._wrap_response(data=self._expand_block(response['block']), metadata=self._get_metadata( request, response))
def block_get(self, request): """ Fetch a list of blocks from the validator """ error_traps = [error_handlers.MissingBlock()] block_id = request.match_info.get('block_id', '') response = self._query_validator( Message.CLIENT_BLOCK_GET_REQUEST, client.ClientBlockGetResponse, client.ClientBlockGetRequest(block_id=block_id), error_traps) return RouteHandler._wrap_response( data=RouteHandler._expand_block(response['block']), metadata=RouteHandler._get_metadata(request, response))
def block_get(self, request): """ Fetch a list of blocks from the validator """ block_id = RouteHandler._safe_get(request.match_info, 'block_id') request = client.ClientBlockGetRequest(block_id=block_id) response = self._query_validator( Message.CLIENT_BLOCK_GET_REQUEST, client.ClientBlockGetResponse, request ) block = RouteHandler._expand_block(response['block']) return RouteHandler._wrap_response(data=block)
def block_get(self, request): """ Fetch a list of blocks from the validator """ error_traps = [error_handlers.MissingBlock()] # aiohttp parses both "+" and "%2B" as " ", so we grab the last segment # of the URL and parse it manually, rather than use `match_info` block_id = unquote(request.url.raw_name) print('BLOCK ID', block_id) response = self._query_validator( Message.CLIENT_BLOCK_GET_REQUEST, client.ClientBlockGetResponse, client.ClientBlockGetRequest(block_id=block_id), error_traps) return RouteHandler._wrap_response( data=RouteHandler._expand_block(response['block']), metadata=RouteHandler._get_metadata(request, response))