Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<fix>(console): fix client rpc interface use sdk nodeName. #797

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .ci/ci_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,24 @@ 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---------"
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"
Expand Down
48 changes: 20 additions & 28 deletions src/main/java/console/client/ConsoleClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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());
}
Expand All @@ -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
Expand Down Expand Up @@ -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());
}
Expand All @@ -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;
Expand All @@ -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());
Expand All @@ -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.");
Expand All @@ -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());
Expand All @@ -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));
}

Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -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);
}
}
Expand Down