async def _get_latest_block_id(self): resp = await self._connection.send( Message.CLIENT_BLOCK_LIST_REQUEST, client_pb2.ClientBlockListRequest(paging=client_pb2.PagingControls( count=1)).SerializeToString()) block_list_resp = client_pb2.ClientBlockListResponse() block_list_resp.ParseFromString(resp.content) if block_list_resp.status != client_pb2.ClientBlockListResponse.OK: LOGGER.error('Unable to fetch latest block id') return block_list_resp.head_id
def _make_paging_message(controls): """Turns a raw paging controls dict into Protobuf PagingControls. """ count = controls.get('count', None) end_index = controls.get('end_index', None) # an end_index must be changed to start_index, possibly modifying count if end_index is not None: if count is None: start_index = 0 count = end_index elif count > end_index + 1: start_index = 0 count = end_index + 1 else: start_index = end_index + 1 - count else: start_index = controls.get('start_index', None) return client_pb2.PagingControls( start_id=controls.get('start_id', None), end_id=controls.get('end_id', None), start_index=start_index, count=count)