Add countTransactions method
This commit is contained in:
parent
d4c57607e2
commit
d3e587f26c
@ -1,10 +1,8 @@
|
|||||||
package bdledger.api;
|
package bdledger.api;
|
||||||
|
|
||||||
import bdledger.api.grpc.common.Block;
|
|
||||||
import bdledger.api.grpc.common.Transaction;
|
|
||||||
import bdledger.api.grpc.node.ClientVersionResponse;
|
|
||||||
import bdledger.api.grpc.common.TransactionType;
|
import bdledger.api.grpc.common.TransactionType;
|
||||||
import bdledger.api.grpc.ledger.*;
|
import bdledger.api.grpc.ledger.*;
|
||||||
|
import bdledger.api.grpc.node.ClientVersionResponse;
|
||||||
import bdledger.api.grpc.node.NodeGrpc;
|
import bdledger.api.grpc.node.NodeGrpc;
|
||||||
import bdledger.api.grpc.query.*;
|
import bdledger.api.grpc.query.*;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
@ -278,7 +276,7 @@ public class Client {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <a
|
* <a
|
||||||
* href="#">返回全网区块的数量</a>
|
* href="#">返回符合条件的区块的数量</a>
|
||||||
* (非阻塞)
|
* (非阻塞)
|
||||||
*/
|
*/
|
||||||
public ListenableFuture<CountBlocksResponse> countBlocks(String ledger) {
|
public ListenableFuture<CountBlocksResponse> countBlocks(String ledger) {
|
||||||
@ -295,7 +293,7 @@ public class Client {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <a
|
* <a
|
||||||
* href="#">返回全网区块的数量</a>
|
* href="#">返回符合条件的区块的数量</a>
|
||||||
* (阻塞)
|
* (阻塞)
|
||||||
*/
|
*/
|
||||||
public CountBlocksResponse countBlocksSync(String ledger) {
|
public CountBlocksResponse countBlocksSync(String ledger) {
|
||||||
@ -414,6 +412,44 @@ public class Client {
|
|||||||
return reqBuilder.build();
|
return reqBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <a
|
||||||
|
* href="#">返回符合条件的数量</a>
|
||||||
|
* (非阻塞)
|
||||||
|
*/
|
||||||
|
public ListenableFuture<CountTransactionsResponse> countTransactions(String ledger) {
|
||||||
|
|
||||||
|
info("*** blockNumber: ledger={0}", ledger);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return queryFutureStub.countTransactions(transactionsRequest(ledger));
|
||||||
|
} catch (StatusRuntimeException e) {
|
||||||
|
warning("RPC failed: {0}", e.getStatus());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <a
|
||||||
|
* href="#">返回符合条件的事务的数量</a>
|
||||||
|
* (阻塞)
|
||||||
|
*/
|
||||||
|
public CountTransactionsResponse countTransactionsSync(String ledger) {
|
||||||
|
|
||||||
|
info("*** blockNumberSync: ledger={0}", ledger);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return queryBlockingStub.countTransactions(transactionsRequest(ledger));
|
||||||
|
} catch (StatusRuntimeException e) {
|
||||||
|
warning("RPC failed: {0}", e.getStatus());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TransactionsRequest transactionsRequest(String ledger) {
|
||||||
|
return TransactionsRequest.newBuilder().setLedger(ledger).build();
|
||||||
|
}
|
||||||
|
|
||||||
private void info(String msg, Object... params) {
|
private void info(String msg, Object... params) {
|
||||||
logger.log(Level.INFO, msg, params);
|
logger.log(Level.INFO, msg, params);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user