diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java b/client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java index 05be78264..1d17ce5ab 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java @@ -3,6 +3,7 @@ import iroha.protocol.QryResponses.AccountAssetResponse; import iroha.protocol.QryResponses.AccountResponse; import iroha.protocol.QryResponses.AssetResponse; +import iroha.protocol.QryResponses.BlockResponse; import iroha.protocol.QryResponses.TransactionsPageResponse; import iroha.protocol.QryResponses.TransactionsResponse; import java.security.KeyPair; @@ -64,6 +65,14 @@ public AccountResponse getAccount(String accountId) { return res.getAccountResponse(); } + public BlockResponse getBlock(Long height) { + val q = Query.builder(this.accountId, counter.getAndIncrement()) + .getBlock(height) + .buildSigned(keyPair); + + return api.query(q).getBlockResponse(); + } + public TransactionsPageResponse getAccountTransactions(String accountId, Integer pageSize, String firstHashHex) { val q = Query.builder(this.accountId, counter.getAndIncrement()) diff --git a/client/src/main/java/jp/co/soramitsu/iroha/java/QueryBuilder.java b/client/src/main/java/jp/co/soramitsu/iroha/java/QueryBuilder.java index 48208070b..b8abf58db 100644 --- a/client/src/main/java/jp/co/soramitsu/iroha/java/QueryBuilder.java +++ b/client/src/main/java/jp/co/soramitsu/iroha/java/QueryBuilder.java @@ -8,6 +8,7 @@ import iroha.protocol.Queries.GetAccountDetail; import iroha.protocol.Queries.GetAccountTransactions; import iroha.protocol.Queries.GetAssetInfo; +import iroha.protocol.Queries.GetBlock; import iroha.protocol.Queries.GetPendingTransactions; import iroha.protocol.Queries.GetRolePermissions; import iroha.protocol.Queries.GetRoles; @@ -234,6 +235,18 @@ public Query getTransactions(Iterable hashes) { return query; } + public Query getBlock(Long height){ + Query query = newQuery(); + + query.getProto().setGetBlock( + GetBlock.newBuilder() + .setHeight(height) + .build() + ); + + return query; + } + public Query getPendingTransactions() { Query query = newQuery();