Skip to content

Commit

Permalink
Add GetPeers Query to iroha-lib
Browse files Browse the repository at this point in the history
Add GetPeers Query to iroha_lib_model

Signed-off-by: Vincent Autefage <vincent.autefage@u-bordeaux.fr>
  • Loading branch information
v-a-net authored and appetrosyan committed Jul 26, 2023
1 parent 0cca973 commit b740d0e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions iroha-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ iroha_lib::GrpcClient(
- [x] [getAssetInfo](https://iroha.readthedocs.io/en/main/develop/api/queries.html#get-asset-info)
- [x] [getRoles](https://iroha.readthedocs.io/en/main/develop/api/queries.html#get-roles)
- [x] [getRolePermissions](https://iroha.readthedocs.io/en/main/develop/api/queries.html#get-role-permissions)
- [x] [getPeers](https://iroha.readthedocs.io/en/main/develop/api/queries.html#get-peers)


## Compatibility and release policy
Expand Down
10 changes: 10 additions & 0 deletions iroha-lib/model/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ Query& Query::getRolePermissions(
return *this;
}

Query& Query::getPeers(const std::string& account_id)
{
protobuf_query_ = *query_generator_.generateGetPeers(
account_id,
counter_,
created_time_);
return *this;
}


const iroha::protocol::Query Query::signAndAddSignature()
{
auto signature = iroha::sign(
Expand Down
1 change: 1 addition & 0 deletions iroha-lib/model/Query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Query {
Query& getRolePermissions(
const std::string& account_id,
const std::string& role_id);
Query& getPeers(const std::string& account_id);

const iroha::protocol::Query signAndAddSignature();

Expand Down
13 changes: 13 additions & 0 deletions iroha-lib/model/generators/QueryGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,17 @@ std::shared_ptr<iroha::protocol::Query> QueryGenerator::generateGetRolePermissio
return query;
}

std::shared_ptr<iroha::protocol::Query> QueryGenerator::generateGetPeers(
const std::string& account_id,
uint64_t counter,
const uint64_t created_time)
{
auto query = generateQuery(
account_id,
counter,
created_time);
query->mutable_payload()->mutable_get_peers();
return query;
}

}
4 changes: 4 additions & 0 deletions iroha-lib/model/generators/QueryGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class QueryGenerator {
uint64_t counter,
const uint64_t created_time,
const std::string& role_id);
std::shared_ptr<iroha::protocol::Query> generateGetPeers(
const std::string& account_id,
uint64_t counter,
const uint64_t created_time);

private:
std::shared_ptr<iroha::protocol::Query> generateQuery(
Expand Down

0 comments on commit b740d0e

Please sign in to comment.