From 6ed41b81774a7926fa95a8d49ec5225f5bc73092 Mon Sep 17 00:00:00 2001 From: kyonRay Date: Thu, 12 Oct 2023 14:33:16 +0800 Subject: [PATCH] (console): fix client rpc interface use sdk nodeName. --- .ci/ci_check.sh | 14 ++++-- .../console/client/ConsoleClientImpl.java | 48 ++++++++----------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.ci/ci_check.sh b/.ci/ci_check.sh index b963339c..a8d8fddc 100755 --- a/.ci/ci_check.sh +++ b/.ci/ci_check.sh @@ -118,9 +118,10 @@ LOG_INFO "------ check java version --------" java -version #cp src/integration-test/resources/config-example.toml src/integration-test/resources/config.toml download_tassl -LOG_INFO "------ download_binary: v3.3.0---------" -download_binary "v3.3.0" -download_build_chain "v3.3.0" + +LOG_INFO "------ download_binary: v3.4.0---------" +download_binary "v3.4.0" +download_build_chain "v3.4.0" LOG_INFO "------ check_standard_node---------" check_standard_node false LOG_INFO "------ check_sm_node---------" @@ -128,6 +129,13 @@ check_sm_node true LOG_INFO "------ check_basic---------" check_basic +LOG_INFO "------ download_binary: v3.3.0---------" +download_binary "v3.3.0" +download_build_chain "v3.3.0" +LOG_INFO "------ check_standard_node---------" +check_standard_node +rm -rf ./bin + LOG_INFO "------ download_binary: v3.2.0---------" download_binary "v3.2.0" download_build_chain "v3.2.0" diff --git a/src/main/java/console/client/ConsoleClientImpl.java b/src/main/java/console/client/ConsoleClientImpl.java index a6316f91..bca4e97b 100644 --- a/src/main/java/console/client/ConsoleClientImpl.java +++ b/src/main/java/console/client/ConsoleClientImpl.java @@ -34,7 +34,6 @@ public class ConsoleClientImpl implements ConsoleClientFace { private static final Logger logger = LoggerFactory.getLogger(ConsoleContractImpl.class); private Client client; - private String nodeName = ""; private static String EMPTY_HASH_HEX = "0x0000000000000000000000000000000000000000000000000000000000000000"; @@ -49,17 +48,17 @@ public void updateClient(Client client) { @Override public void getBlockNumber(String[] params) throws IOException { - System.out.println(client.getBlockNumber(nodeName).getBlockNumber()); + System.out.println(client.getBlockNumber().getBlockNumber()); } @Override public void getPbftView(String[] params) throws IOException { - System.out.println(client.getPbftView(nodeName).getPbftView()); + System.out.println(client.getPbftView().getPbftView()); } @Override public void getObserverList(String[] params) throws IOException { - String observers = client.getObserverList(nodeName).getObserverList().toString(); + String observers = client.getObserverList().getObserverList().toString(); if ("[]".equals(observers)) { System.out.println("[]"); } else { @@ -69,7 +68,7 @@ public void getObserverList(String[] params) throws IOException { @Override public void getSealerList(String[] params) throws IOException { - String sealers = client.getSealerList(nodeName).getSealerList().toString(); + String sealers = client.getSealerList().getSealerList().toString(); if ("[]".equals(sealers)) { System.out.println("[]"); } else { @@ -80,9 +79,7 @@ public void getSealerList(String[] params) throws IOException { @Override public void getCandidateSealerList(String[] params) throws IOException { String sealers = - client.getNodeListByType(nodeName, "consensus_candidate_sealer") - .getSealerList() - .toString(); + client.getNodeListByType("consensus_candidate_sealer").getSealerList().toString(); if ("[]".equals(sealers)) { System.out.println("[]"); } else { @@ -92,7 +89,7 @@ public void getCandidateSealerList(String[] params) throws IOException { @Override public void getSyncStatus(String[] params) throws IOException { - ConsoleUtils.printJson(client.getSyncStatus(nodeName).getSyncStatus().toString()); + ConsoleUtils.printJson(client.getSyncStatus().getSyncStatus().toString()); } @Override @@ -120,7 +117,7 @@ public void getBlockByHash(String[] params) throws IOException { return; } } - BcosBlock.Block block = client.getBlockByHash(nodeName, blockHash, false, flag).getBlock(); + BcosBlock.Block block = client.getBlockByHash(blockHash, false, flag).getBlock(); if (block == null) { System.out.println("Block can not ne found, please check hash: " + blockHash); return; @@ -147,12 +144,12 @@ public void getBlockByNumber(String[] params) throws IOException { } } BcosBlock blockByNumber = - client.getBlockByNumber(nodeName, BigInteger.valueOf(blockNumber), false, flag); + client.getBlockByNumber(BigInteger.valueOf(blockNumber), false, flag); if (blockByNumber.getBlock() == null) { System.out.println("Block not found, please check number: " + blockNumber); } else { ConsoleUtils.printJson( - client.getBlockByNumber(nodeName, BigInteger.valueOf(blockNumber), false, flag) + client.getBlockByNumber(BigInteger.valueOf(blockNumber), false, flag) .getBlock() .toString()); } @@ -162,8 +159,7 @@ public void getBlockByNumber(String[] params) throws IOException { public void getBlockHeaderByHash(String[] params) throws IOException { String blockHash = params[1]; if (ConsoleUtils.isInvalidHash(blockHash)) return; - ConsoleUtils.printJson( - client.getBlockByHash(nodeName, blockHash, true, false).getBlock().toString()); + ConsoleUtils.printJson(client.getBlockByHash(blockHash, true, false).getBlock().toString()); } @Override @@ -192,7 +188,7 @@ public void getBlockHeaderByNumber(String[] params) throws IOException { return; } ConsoleUtils.printJson( - client.getBlockByNumber(nodeName, BigInteger.valueOf(blockNumber), true, false) + client.getBlockByNumber(BigInteger.valueOf(blockNumber), true, false) .getBlock() .toString()); } @@ -202,7 +198,7 @@ public void getTransactionByHash(String[] params) { String transactionHash = params[1]; if (ConsoleUtils.isInvalidHash(transactionHash)) return; JsonTransactionResponse transaction = - client.getTransaction(nodeName, transactionHash, false).getTransaction().get(); + client.getTransaction(transactionHash, false).getTransaction().get(); if (transaction == null) { System.out.println("This transaction hash doesn't exist."); return; @@ -216,9 +212,7 @@ public void getTransactionReceipt(String[] params) throws Exception { if (ConsoleUtils.isInvalidHash(transactionHash)) return; TransactionReceipt receipt = null; try { - receipt = - client.getTransactionReceipt(nodeName, transactionHash, false) - .getTransactionReceipt(); + receipt = client.getTransactionReceipt(transactionHash, false).getTransactionReceipt(); } catch (ClientException e) { System.out.println( "This transaction hash doesn't exist, errorMsg:" + e.getErrorMessage()); @@ -237,7 +231,7 @@ public void getTransactionByHashWithProof(String[] params) throws Exception { String transactionHash = params[1]; if (ConsoleUtils.isInvalidHash(transactionHash)) return; String transactionWithProof = - client.getTransaction(nodeName, transactionHash, true).getResult().toString(); + client.getTransaction(transactionHash, true).getResult().toString(); if (Objects.isNull(transactionWithProof) || transactionWithProof.isEmpty()) { System.out.println("This transaction hash doesn't exist."); @@ -253,9 +247,7 @@ public void getTransactionReceiptByHashWithProof(String[] params) throws Excepti String transactionReceiptWithProof; try { transactionReceiptWithProof = - client.getTransactionReceipt(nodeName, transactionHash, true) - .getResult() - .toString(); + client.getTransactionReceipt(transactionHash, true).getResult().toString(); } catch (ClientException e) { System.out.println( "This transaction hash doesn't exist, errorMsg:" + e.getErrorMessage()); @@ -271,7 +263,7 @@ public void getTransactionReceiptByHashWithProof(String[] params) throws Excepti @Override public void getPendingTxSize(String[] params) throws IOException { - String size = client.getPendingTxSize(nodeName).getResult(); + String size = client.getPendingTxSize().getResult(); System.out.println(Numeric.decodeQuantity(size)); } @@ -291,7 +283,7 @@ public void getCode(String[] params, boolean isWasm, String pwd) throws IOExcept return; } } - String code = client.getCode(nodeName, address).getCode(); + String code = client.getCode(address).getCode(); if ("0x".equals(code) || code.isEmpty()) { System.out.println("This address doesn't exist."); return; @@ -303,7 +295,7 @@ public void getCode(String[] params, boolean isWasm, String pwd) throws IOExcept public void getTotalTransactionCount(String[] params) throws IOException { TotalTransactionCount.TransactionCountInfo transactionCount = - client.getTotalTransactionCount(nodeName).getTotalTransactionCount(); + client.getTotalTransactionCount().getTotalTransactionCount(); TotalTransactionCountResult innerTotalTransactionCountResult = new TotalTransactionCountResult(); @@ -325,11 +317,11 @@ public void getTotalTransactionCount(String[] params) throws IOException { @Override public void getSystemConfigByKey(String[] params) throws Exception { String key = params[1]; - SystemConfig systemConfigByKey = client.getSystemConfigByKey(nodeName, key); + SystemConfig systemConfigByKey = client.getSystemConfigByKey(key); if (systemConfigByKey.getSystemConfig() == null) { System.out.println("System config not found, please check key: " + key); } else { - String value = client.getSystemConfigByKey(nodeName, key).getSystemConfig().getValue(); + String value = client.getSystemConfigByKey(key).getSystemConfig().getValue(); System.out.println(value); } }