diff --git a/build.gradle b/build.gradle index 5f8c5e3..4d0b90e 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,20 @@ sourceCompatibility = 1.8 def grpc_java_version = '1.14.0' +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +javadoc { + source = sourceSets.main.allJava + classpath = configurations.compile + options { + encoding 'UTF-8' + charSet 'UTF-8' + title "BDChain Java SDK API" + } +} + protobuf { protoc { artifact = "com.google.protobuf:protoc:3.6.0" diff --git a/src/main/java/bdchain/api/AccountingChainClient.java b/src/main/java/bdchain/api/AccountingChainClient.java index 124b6e1..b146b4c 100644 --- a/src/main/java/bdchain/api/AccountingChainClient.java +++ b/src/main/java/bdchain/api/AccountingChainClient.java @@ -15,6 +15,14 @@ import java.util.logging.Logger; // import bdchain.api.grpc.AccountingChainGrpc.AccountingChainStub; +/** + * 记账链客户端 + * + *
如有更灵活的需求可直接使用{@link bdchain.api.grpc.AccountingChainGrpc}类。
+ *
+ * @see 记账链API
+ * @author nex
+ */
public class AccountingChainClient {
private static final Logger logger = Logger.getLogger(AccountingChainClient.class.getName());
@@ -22,26 +30,32 @@ public class AccountingChainClient {
private final ManagedChannel channel;
private final AccountingChainFutureStub futureStub;
private final AccountingChainBlockingStub blockingStub;
- // private final AccountingChainStub asyncStub;
+// private final AccountingChainStub asyncStub;
- /** Construct client for accessing AccountingChain server at {@code host:port}. */
+ /** 构造客户端来访问{@code host:port}的记账链服务。 */
public AccountingChainClient(String host, int port) {
this(ManagedChannelBuilder.forAddress(host, port).usePlaintext());
}
- /** Construct client for accessing AccountingChain server using the existing channel. */
+ /** 用已有的{@link io.grpc.Channel}对象构造客户端来访问记账链服务。 */
public AccountingChainClient(ManagedChannelBuilder> channelBuilder) {
channel = channelBuilder.build();
AccountingChainGrpc.newFutureStub(channel);
futureStub = AccountingChainGrpc.newFutureStub(channel);
blockingStub = AccountingChainGrpc.newBlockingStub(channel);
- // asyncStub = AccountingChainGrpc.newStub(channel);
+// asyncStub = AccountingChainGrpc.newStub(channel);
}
+ /** 关闭客户端的网络连接。 */
public void shutdown() throws InterruptedException {
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
+ /**
+ * 返回最新区块的区块号
+ * (非阻塞)
+ */
public ListenableFuture 如有更灵活的需求可直接使用{@link bdchain.api.grpc.TransactionLedgerGrpc}类。
+ *
+ * @see 事务账本API
+ * @author nex
+ */
public class TransactionLedgerClient {
private static final Logger logger = Logger.getLogger(TransactionLedgerClient.class.getName());
@@ -25,12 +33,12 @@ public class TransactionLedgerClient {
private final TransactionLedgerBlockingStub blockingStub;
// private final TransactionLedgerStub asyncStub;
- /** Construct client for accessing TransactionLedger server at {@code host:port}. */
+ /** 构造客户端来访问{@code host:port}的事务账本服务。 */
public TransactionLedgerClient(String host, int port) {
this(ManagedChannelBuilder.forAddress(host, port).usePlaintext());
}
- /** Construct client for accessing TransactionLedger server using the existing channel. */
+ /** 用已有的{@link io.grpc.Channel}对象构造客户端来访问事务账本服务。 */
public TransactionLedgerClient(ManagedChannelBuilder> channelBuilder) {
channel = channelBuilder.build();
futureStub = TransactionLedgerGrpc.newFutureStub(channel);
@@ -38,10 +46,15 @@ public class TransactionLedgerClient {
// asyncStub = TransactionLedgerGrpc.newStub(channel);
}
+ /** 关闭客户端的网络连接。 */
public void shutdown() throws InterruptedException {
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
}
+ /**
+ * 创建账本
+ * (非阻塞)
+ */
public ListenableFuture