Add javadoc
This commit is contained in:
@@ -16,6 +16,14 @@ import java.util.logging.Logger;
|
||||
|
||||
// import bdchain.api.grpc.TransactionLedgerGrpc.TransactionLedgerStub;
|
||||
|
||||
/**
|
||||
* 事务账本客户端
|
||||
*
|
||||
* <p>如有更灵活的需求可直接使用{@link bdchain.api.grpc.TransactionLedgerGrpc}类。
|
||||
*
|
||||
* @see <a href="https://phabricator.internetapi.cn/w/public/bdchain/grpc-api/#api">事务账本API</a>
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="https://phabricator.internetapi.cn/w/public/bdchain/grpc-api/#createledger">创建账本</a>
|
||||
* (非阻塞)
|
||||
*/
|
||||
public ListenableFuture<CreateLedgerResponse> createLedger(String name) {
|
||||
|
||||
info("*** createLedger: name={0}", name);
|
||||
@@ -56,6 +69,10 @@ public class TransactionLedgerClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="https://phabricator.internetapi.cn/w/public/bdchain/grpc-api/#createledger">创建账本</a>
|
||||
* (阻塞)
|
||||
*/
|
||||
public CreateLedgerResponse createLedgerSync(String name) {
|
||||
|
||||
info("*** createLedgerSync: name={0}", name);
|
||||
@@ -70,6 +87,10 @@ public class TransactionLedgerClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="https://phabricator.internetapi.cn/w/public/bdchain/grpc-api/#getledgers">返回账本列表</a>
|
||||
* (非阻塞)
|
||||
*/
|
||||
public ListenableFuture<GetLedgersResponse> getLedgers() {
|
||||
|
||||
info("*** getLedgers");
|
||||
@@ -82,6 +103,10 @@ public class TransactionLedgerClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <a href="https://phabricator.internetapi.cn/w/public/bdchain/grpc-api/#getledgers">返回账本列表</a>
|
||||
* (阻塞)
|
||||
*/
|
||||
public GetLedgersResponse getLedgersSync() {
|
||||
|
||||
info("*** getLedgersSync");
|
||||
@@ -94,6 +119,11 @@ public class TransactionLedgerClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <a
|
||||
* href="https://phabricator.internetapi.cn/w/public/bdchain/grpc-api/#sendtransaction">发送新事务</a>
|
||||
* (非阻塞)
|
||||
*/
|
||||
public ListenableFuture<SendTransactionResponse> sendTransaction(
|
||||
String ledger, TransactionType type, String from, String to, byte[] data) {
|
||||
|
||||
@@ -120,6 +150,11 @@ public class TransactionLedgerClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <a
|
||||
* href="https://phabricator.internetapi.cn/w/public/bdchain/grpc-api/#sendtransaction">发送新事务</a>
|
||||
* (阻塞)
|
||||
*/
|
||||
public SendTransactionResponse sendTransactionSync(
|
||||
String ledger, TransactionType type, String from, String to, byte[] data) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user