diff --git a/src/main/java/bdchain/api/AccountingChainClient.java b/src/main/java/bdchain/api/AccountingChainClient.java
index b146b4c..c8844f4 100644
--- a/src/main/java/bdchain/api/AccountingChainClient.java
+++ b/src/main/java/bdchain/api/AccountingChainClient.java
@@ -5,6 +5,7 @@ import bdchain.api.grpc.AccountingChainGrpc.AccountingChainBlockingStub;
import bdchain.api.grpc.AccountingChainGrpc.AccountingChainFutureStub;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.protobuf.ByteString;
+import com.google.protobuf.Empty;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.StatusRuntimeException;
@@ -30,7 +31,7 @@ public class AccountingChainClient {
private final ManagedChannel channel;
private final AccountingChainFutureStub futureStub;
private final AccountingChainBlockingStub blockingStub;
-// private final AccountingChainStub asyncStub;
+ // private final AccountingChainStub asyncStub;
/** 构造客户端来访问{@code host:port}的记账链服务。 */
public AccountingChainClient(String host, int port) {
@@ -43,7 +44,7 @@ public class AccountingChainClient {
AccountingChainGrpc.newFutureStub(channel);
futureStub = AccountingChainGrpc.newFutureStub(channel);
blockingStub = AccountingChainGrpc.newBlockingStub(channel);
-// asyncStub = AccountingChainGrpc.newStub(channel);
+ // asyncStub = AccountingChainGrpc.newStub(channel);
}
/** 关闭客户端的网络连接。 */
@@ -51,6 +52,40 @@ public class AccountingChainClient {
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
+ /**
+ * 查询节点客户端版本
+ * (非阻塞)
+ */
+ public ListenableFuture clientVersion() {
+
+ info("*** clientVersion");
+
+ try {
+ return futureStub.clientVersion(Empty.getDefaultInstance());
+ } catch (StatusRuntimeException e) {
+ warning("RPC failed: {0}", e.getStatus());
+ return null;
+ }
+ }
+
+ /**
+ * 查询节点客户端版本
+ * (阻塞)
+ */
+ public ClientVersionResponse clientVersionSync() {
+
+ info("*** clientVersionSync");
+
+ try {
+ return blockingStub.clientVersion(Empty.getDefaultInstance());
+ } catch (StatusRuntimeException e) {
+ warning("RPC failed: {0}", e.getStatus());
+ return null;
+ }
+ }
+
/**
* 返回最新区块的区块号
diff --git a/src/main/java/bdchain/api/TransactionLedgerClient.java b/src/main/java/bdchain/api/TransactionLedgerClient.java
index 421baa2..1432ae9 100644
--- a/src/main/java/bdchain/api/TransactionLedgerClient.java
+++ b/src/main/java/bdchain/api/TransactionLedgerClient.java
@@ -51,6 +51,40 @@ public class TransactionLedgerClient {
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
+ /**
+ * 查询节点客户端版本
+ * (非阻塞)
+ */
+ public ListenableFuture clientVersion() {
+
+ info("*** clientVersion");
+
+ try {
+ return futureStub.clientVersion(Empty.getDefaultInstance());
+ } catch (StatusRuntimeException e) {
+ warning("RPC failed: {0}", e.getStatus());
+ return null;
+ }
+ }
+
+ /**
+ * 查询节点客户端版本
+ * (阻塞)
+ */
+ public ClientVersionResponse clientVersionSync() {
+
+ info("*** clientVersionSync");
+
+ try {
+ return blockingStub.clientVersion(Empty.getDefaultInstance());
+ } catch (StatusRuntimeException e) {
+ warning("RPC failed: {0}", e.getStatus());
+ return null;
+ }
+ }
+
/**
* 创建账本
* (非阻塞)