Skip to content

Commit

Permalink
Add GetBlock
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Vaneev <warchantua@gmail.com>
  • Loading branch information
Warchant committed Mar 4, 2019
1 parent 5a011c3 commit 3392822
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
13 changes: 13 additions & 0 deletions client/src/main/java/jp/co/soramitsu/iroha/java/QueryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -234,6 +235,18 @@ public Query getTransactions(Iterable<String> 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();

Expand Down

0 comments on commit 3392822

Please sign in to comment.