private static async Task <QueryDataRpcResponse> GetTargetChainDataAsync(string address, string tableName, ILogger logger) { var tableresponse = await new JsonRpcRequest { Method = Commands.ListTables, }.ConnectAndRequest <ListTablesRpcResponse>(address); var tables = tableresponse.Result.Tables; if (tables.All(_ => _.Name != tableName)) { throw new ArgumentException($"Table [{tableName}] not exist in target [{address}]."); } var result = new QueryDataRpcResponse(); var data = new List <string>(); var dataHistories = new List <HistoryEntry>(); using (var client = new WebApiClient()) { try { await client.ConnectAsync(address); } catch (ApiClientException acex) { throw new ApiClientException($"Cannot connect to server {address}, due to {acex.Message}", acex); } if (!client.IsConnected) { throw new ApiClientException($"open channel failed"); } var pos = 0; while (true) { var request = new JsonRpcRequest { Method = Commands.QueryData, Parameters = new QueryDataRpcRequest { TableName = tableName, Start = pos, Count = 100, } }; var response = await client.RequestAsync <QueryDataRpcResponse>(request); var query = response.Result; if (result.Headers == null) { result.Headers = query.Headers; result.HeaderHistories = query.HeaderHistories; result.PrimaryKeyName = query.PrimaryKeyName; } if (query.Rows.Length == 0) { break; } data.AddRange(query.Data); dataHistories.AddRange(query.DataHistories); pos += query.Rows.Length; } } result.Data = data.ToArray(); result.DataHistories = dataHistories.ToArray(); return(result); }