Skip to content

Commit 0fac96f

Browse files
authored
Merge pull request #3697 from tronprotocol/modify-tx-return-value
Modify tx return value
2 parents 65f5b44 + 824f9a7 commit 0fac96f

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

framework/src/main/java/org/tron/core/services/http/GetTransactionListFromPendingServlet.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package org.tron.core.services.http;
22

3-
import com.google.protobuf.ByteString;
43
import java.util.Collection;
54
import javax.servlet.http.HttpServletRequest;
65
import javax.servlet.http.HttpServletResponse;
76
import lombok.extern.slf4j.Slf4j;
87
import org.springframework.beans.factory.annotation.Autowired;
98
import org.springframework.stereotype.Component;
109
import org.tron.api.GrpcAPI.TransactionIdList;
11-
import org.tron.api.GrpcAPI.TransactionList;
1210
import org.tron.core.db.Manager;
13-
import org.tron.protos.Protocol.Transaction;
1411

1512

1613
@Component
@@ -26,7 +23,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
2623
Collection<String> result = manager.getTxListFromPending();
2724
TransactionIdList.Builder builder = TransactionIdList.newBuilder();
2825
builder.addAllTxId(result);
29-
response.getWriter().println(Util.printTransactionList(builder.build(), visible));
26+
response.getWriter().println(Util.printTransactionIdList(builder.build(), visible));
3027
} catch (Exception e) {
3128
Util.processError(e, response);
3229
}
@@ -39,7 +36,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
3936
TransactionIdList.Builder builder = TransactionIdList.newBuilder();
4037
builder.addAllTxId(result);
4138
response.getWriter()
42-
.println(Util.printTransactionList(builder.build(), params.isVisible()));
39+
.println(Util.printTransactionIdList(builder.build(), params.isVisible()));
4340
} catch (Exception e) {
4441
Util.processError(e, response);
4542
}

framework/src/main/java/org/tron/core/services/http/Util.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public class Util {
5858
public static final String PERMISSION_ID = "Permission_id";
5959
public static final String VISIBLE = "visible";
6060
public static final String TRANSACTION = "transaction";
61-
public static final String TRANSACTION_ID = "transactionId";
6261
public static final String VALUE = "value";
6362
public static final String CONTRACT_TYPE = "contractType";
6463
public static final String EXTRA_DATA = "extra_data";
@@ -114,13 +113,9 @@ public static String printTransactionList(TransactionList list, boolean selfType
114113
return jsonObject.toJSONString();
115114
}
116115

117-
public static String printTransactionList(TransactionIdList list, boolean selfType) {
116+
public static String printTransactionIdList(TransactionIdList list, boolean selfType) {
118117
List<String> transactions = list.getTxIdList();
119118
JSONObject jsonObject = JSONObject.parseObject(JsonFormat.printToString(list, selfType));
120-
JSONArray jsonArray = new JSONArray();
121-
transactions.stream()
122-
.forEach(transaction -> jsonArray.add(transaction));
123-
jsonObject.put(TRANSACTION_ID, jsonArray);
124119

125120
return jsonObject.toJSONString();
126121
}

framework/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestTransactionPending001.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,12 @@ public void test02GetPendingTransactionList() {
6464
if (retryTimes % 5 == 0) {
6565
response = HttpMethed.getTransactionListFromPending(httpnode);
6666
responseContent = HttpMethed.parseResponseContent(response);
67-
transactionSize = responseContent.getJSONArray("transaction").size();
67+
transactionSize = responseContent.getJSONArray("txId").size();
6868
}
6969
}
7070
Assert.assertNotEquals(transactionSize,0);
7171

72-
transaction = responseContent.getJSONArray("transaction").getJSONObject(0);
73-
HttpMethed.printJsonContent(transaction);
74-
txid = transaction.getString("txID");
75-
Assert.assertTrue(transaction.containsKey("raw_data"));
72+
txid = responseContent.getJSONArray("txId").getString(0);
7673
}
7774

7875

0 commit comments

Comments
 (0)