Skip to content

Commit 48e13b8

Browse files
committed
feat(msg): optimize information display
1 parent 0c1c859 commit 48e13b8

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/main/java/org/tron/common/utils/HttpUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ private static String responseBodyToString(Response response) throws IOException
6464
}
6565
}).orElse(EMPTY);
6666
}
67+
if (response.code() == 502) {
68+
throw new IOException("Unexpected HTTP code " + response.code() + ": Bad Gateway.");
69+
}
6770
throw new IOException(
6871
"Unexpected HTTP code " + response.code() + ": " + msg + "\nAPI authentication failed, "
6972
+ "please check the " + greenBoldHighlight("apikey") + " and "

src/main/java/org/tron/ledger/listener/LedgerEventListener.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.tron.ledger.sdk.LedgerConstant;
2121
import org.tron.ledger.sdk.LedgerProtocol;
2222
import org.tron.ledger.wrapper.DebugConfig;
23-
import org.tron.ledger.wrapper.HidServicesWrapper;
2423
import org.tron.ledger.wrapper.LedgerSignResult;
2524
import org.tron.protos.Protocol;
2625
import org.tron.protos.Protocol.Transaction;

src/main/java/org/tron/walletcli/Client.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,11 @@ private void switchNetwork(String[] parameters) throws InterruptedException {
795795
} else if (parameters.length == 2) {
796796
fullNode = parameters[0];
797797
solidityNode = parameters[1];
798+
if (EMPTY_STR.equalsIgnoreCase(fullNode) && EMPTY_STR.equalsIgnoreCase(solidityNode)) {
799+
System.out.println("Both fullnode and solidity cannot be empty at the same time.");
800+
System.out.println("SwitchNetwork " + failedHighlight() + " !!!");
801+
return;
802+
}
798803
if (EMPTY_STR.equalsIgnoreCase(fullNode)) {
799804
fullNode = EMPTY;
800805
}
@@ -5627,10 +5632,10 @@ private void gasFreeTrace(String[] parameters) throws IOException, NoSuchAlgorit
56275632
private void currentNetwork() {
56285633
NetType currentNet = WalletApi.getCurrentNetwork();
56295634
Pair<String, String> customNodes = WalletApi.getCustomNodes();
5630-
if (customNodes == null || (org.apache.commons.lang3.StringUtils.isEmpty(customNodes.getLeft())
5631-
&& org.apache.commons.lang3.StringUtils.isEmpty(customNodes.getRight()))) {
5632-
System.out.println("The configuration of both fullnode and solidity cannot be empty at the same time.");
5633-
return;
5635+
if (currentNet == CUSTOM && (customNodes == null || (org.apache.commons.lang3.StringUtils.isEmpty(customNodes.getLeft())
5636+
&& org.apache.commons.lang3.StringUtils.isEmpty(customNodes.getRight())))) {
5637+
System.out.println("The configuration of both fullnode and solidity cannot be empty at the same time.");
5638+
return;
56345639
}
56355640
String fullNode = customNodes.getLeft();
56365641
String solidityNode = customNodes.getRight();

src/main/java/org/tron/walletcli/WalletApiWrapper.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,7 +2724,7 @@ private Pair<GrpcClient, NetType> getGrpcClientAndNetType(String netWorkSymbol,
27242724
}
27252725
if (StringUtils.isEmpty(fullNode) && StringUtils.isEmpty(solidityNode)) {
27262726
throw new IllegalArgumentException("The configuration of fullnode.ip.list or " +
2727-
"soliditynode.ip.list in config. conf is incorrect.");
2727+
"soliditynode.ip.list in config.conf is incorrect.");
27282728
}
27292729
if (NILE.getGrpc().getFullNode().equals(fullNode) && NILE.getGrpc().getSolidityNode().equals(solidityNode)){
27302730
currentNet = NILE;
@@ -2876,13 +2876,15 @@ public boolean gasFreeTransfer(String receiver, long value) throws NoSuchAlgorit
28762876
boolean ledgerResult = LedgerSignUtil.requestLedgerSignLogic(transaction, ledgerPath, wf.getAddress(), true);
28772877
if (ledgerResult) {
28782878
signature = TransactionSignManager.getInstance().getGasfreeSignature();
2879-
if (Objects.isNull(signature)) {
2880-
System.out.println("Listening ledger did not obtain signature.");
2881-
return false;
2882-
}
2879+
}
2880+
if (Objects.isNull(signature)) {
2881+
System.out.println("Listening ledger did not obtain signature.");
28832882
TransactionSignManager.getInstance().setTransaction(null);
28842883
TransactionSignManager.getInstance().setGasfreeSignature(null);
2884+
return false;
28852885
}
2886+
TransactionSignManager.getInstance().setTransaction(null);
2887+
TransactionSignManager.getInstance().setGasfreeSignature(null);
28862888
} else {
28872889
signature = signOffChain(keccak256(concat), privateKey);
28882890
}

0 commit comments

Comments
 (0)