hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
query_response_factory.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_QUERY_RESPONSE_FACTORY_HPP
7 #define IROHA_QUERY_RESPONSE_FACTORY_HPP
8 
9 #include <memory>
10 
11 #include <boost/optional.hpp>
18 
19 namespace shared_model {
20  namespace crypto {
21  class Hash;
22  }
23  namespace interface {
24  class Block;
25  class Amount;
26  } // namespace interface
27 } // namespace shared_model
28 
29 namespace shared_model {
30  namespace interface {
31 
36  public:
37  virtual ~QueryResponseFactory() = default;
38 
49  virtual std::unique_ptr<QueryResponse> createAccountAssetResponse(
50  std::vector<std::tuple<types::AccountIdType,
53  size_t total_assets_number,
54  boost::optional<shared_model::interface::types::AssetIdType>
55  next_asset_id,
56  const crypto::Hash &query_hash) const = 0;
57 
64  virtual std::unique_ptr<QueryResponse> createAccountDetailResponse(
65  types::DetailType account_detail,
66  const crypto::Hash &query_hash) const = 0;
67 
78  virtual std::unique_ptr<QueryResponse> createAccountResponse(
83  std::vector<std::string> roles,
84  const crypto::Hash &query_hash) const = 0;
85 
92  virtual std::unique_ptr<QueryResponse> createBlockResponse(
93  std::unique_ptr<Block> block,
94  const crypto::Hash &query_hash) const = 0;
95 
99  enum class ErrorQueryType {
100  kStatelessFailed,
101  kStatefulFailed,
102  kNoAccount,
103  kNoAccountAssets,
104  kNoAccountDetail,
105  kNoSignatories,
106  kNotSupported,
107  kNoAsset,
108  kNoRoles
109  };
118  virtual std::unique_ptr<QueryResponse> createErrorQueryResponse(
119  ErrorQueryType error_type,
122  const crypto::Hash &query_hash) const = 0;
123 
130  virtual std::unique_ptr<QueryResponse> createSignatoriesResponse(
131  std::vector<types::PubkeyType> signatories,
132  const crypto::Hash &query_hash) const = 0;
133 
140  virtual std::unique_ptr<QueryResponse> createTransactionsResponse(
141  std::vector<std::unique_ptr<shared_model::interface::Transaction>>
142  transactions,
143  const crypto::Hash &query_hash) const = 0;
144 
155  virtual std::unique_ptr<QueryResponse> createTransactionsPageResponse(
156  std::vector<std::unique_ptr<shared_model::interface::Transaction>>
157  transactions,
158  const crypto::Hash &next_tx_hash,
159  interface::types::TransactionsNumberType all_transactions_size,
160  const crypto::Hash &query_hash) const = 0;
161 
170  virtual std::unique_ptr<QueryResponse> createTransactionsPageResponse(
171  std::vector<std::unique_ptr<shared_model::interface::Transaction>>
172  transactions,
173  interface::types::TransactionsNumberType all_transactions_size,
174  const crypto::Hash &query_hash) const = 0;
175 
184  virtual std::unique_ptr<QueryResponse> createAssetResponse(
185  types::AssetIdType asset_id,
186  types::DomainIdType domain_id,
187  types::PrecisionType precision,
188  const crypto::Hash &query_hash) const = 0;
189 
196  virtual std::unique_ptr<QueryResponse> createRolesResponse(
197  std::vector<types::RoleIdType> roles,
198  const crypto::Hash &query_hash) const = 0;
199 
206  virtual std::unique_ptr<QueryResponse> createRolePermissionsResponse(
207  RolePermissionSet role_permissions,
208  const crypto::Hash &query_hash) const = 0;
209 
215  virtual std::unique_ptr<BlockQueryResponse> createBlockQueryResponse(
216  std::shared_ptr<const Block> block) const = 0;
217 
223  virtual std::unique_ptr<BlockQueryResponse> createBlockQueryResponse(
224  std::string error_message) const = 0;
225  };
226 
227  } // namespace interface
228 } // namespace shared_model
229 
230 #endif // IROHA_QUERY_RESPONSE_FACTORY_HPP
Definition: hash.hpp:18
std::string ErrorMessageType
Message type.
Definition: error_query_response.hpp:56
std::string DomainIdType
Iroha domain id type.
Definition: types.hpp:51
Definition: permissions.hpp:92
Definition: amount.hpp:20
Definition: query_response_factory.hpp:35
std::string DetailType
Type of detail.
Definition: types.hpp:69
std::string AccountIdType
Type of account id.
Definition: types.hpp:37
ErrorQueryType
Definition: query_response_factory.hpp:99
uint8_t PrecisionType
Type of precision.
Definition: types.hpp:39
uint32_t ErrorCodeType
Error code type.
Definition: error_query_response.hpp:64
uint16_t TransactionsNumberType
Type of a number of transactions in block and query response page.
Definition: types.hpp:77
Definition: command_executor.hpp:12
uint16_t QuorumType
Type of Quorum used in transaction and set quorum.
Definition: types.hpp:59
std::string JsonType
Type of JSON data.
Definition: types.hpp:71
std::string AssetIdType
Type of asset id.
Definition: types.hpp:53