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 <optional>
22 
23 namespace shared_model {
24  namespace crypto {
25  class Hash;
26  }
27  namespace interface {
28  class Block;
29  class Amount;
30  } // namespace interface
31 } // namespace shared_model
32 
33 namespace shared_model {
34  namespace interface {
35 
40  public:
41  virtual ~QueryResponseFactory() = default;
42 
53  virtual std::unique_ptr<QueryResponse> createAccountAssetResponse(
54  std::vector<std::tuple<types::AccountIdType,
57  size_t total_assets_number,
58  std::optional<shared_model::interface::types::AssetIdType>
59  next_asset_id,
60  const crypto::Hash &query_hash) const = 0;
61 
71  virtual std::unique_ptr<QueryResponse> createAccountDetailResponse(
72  types::DetailType account_detail,
73  size_t total_number,
74  std::optional<std::reference_wrapper<
76  next_record_id,
77  const crypto::Hash &query_hash) const = 0;
78 
89  virtual std::unique_ptr<QueryResponse> createAccountResponse(
94  std::vector<std::string> roles,
95  const crypto::Hash &query_hash) const = 0;
96 
103  virtual std::unique_ptr<QueryResponse> createBlockResponse(
104  std::unique_ptr<Block> block,
105  const crypto::Hash &query_hash) const = 0;
106 
110  enum class ErrorQueryType {
111  kStatelessFailed,
112  kStatefulFailed,
113  kNoAccount,
114  kNoAccountAssets,
115  kNoAccountDetail,
116  kNoSignatories,
117  kNotSupported,
118  kNoAsset,
119  kNoRoles
120  };
129  virtual std::unique_ptr<QueryResponse> createErrorQueryResponse(
130  ErrorQueryType error_type,
133  const crypto::Hash &query_hash) const = 0;
134 
141  virtual std::unique_ptr<QueryResponse> createSignatoriesResponse(
142  std::vector<std::string> signatories,
143  const crypto::Hash &query_hash) const = 0;
144 
151  virtual std::unique_ptr<QueryResponse> createTransactionsResponse(
152  std::vector<std::unique_ptr<shared_model::interface::Transaction>>
153  transactions,
154  const crypto::Hash &query_hash) const = 0;
155 
166  virtual std::unique_ptr<QueryResponse> createTransactionsPageResponse(
167  std::vector<std::unique_ptr<shared_model::interface::Transaction>>
168  transactions,
169  std::optional<std::reference_wrapper<const crypto::Hash>>
170  next_tx_hash,
171  interface::types::TransactionsNumberType all_transactions_size,
172  const crypto::Hash &query_hash) const = 0;
173 
183  virtual std::unique_ptr<QueryResponse>
184  createPendingTransactionsPageResponse(
185  std::vector<std::unique_ptr<interface::Transaction>> transactions,
186  interface::types::TransactionsNumberType all_transactions_size,
187  std::optional<interface::PendingTransactionsPageResponse::BatchInfo>
188  next_batch_info,
189  const crypto::Hash &query_hash) const = 0;
190 
200  virtual std::unique_ptr<QueryResponse> createAssetResponse(
201  types::AssetIdType asset_id,
202  types::DomainIdType domain_id,
203  types::PrecisionType precision,
204  const crypto::Hash &query_hash) const = 0;
205 
212  virtual std::unique_ptr<QueryResponse> createRolesResponse(
213  std::vector<types::RoleIdType> roles,
214  const crypto::Hash &query_hash) const = 0;
215 
222  virtual std::unique_ptr<QueryResponse> createRolePermissionsResponse(
223  RolePermissionSet role_permissions,
224  const crypto::Hash &query_hash) const = 0;
225 
232  virtual std::unique_ptr<QueryResponse> createPeersResponse(
233  types::PeerList peers, const crypto::Hash &query_hash) const = 0;
234 
241  virtual std::unique_ptr<QueryResponse> createEngineReceiptsResponse(
242  const std::vector<std::unique_ptr<EngineReceipt>>
243  &engine_response_records,
244  const crypto::Hash &query_hash) const = 0;
245 
251  virtual std::unique_ptr<BlockQueryResponse> createBlockQueryResponse(
252  std::shared_ptr<const Block> block) const = 0;
253 
259  virtual std::unique_ptr<BlockQueryResponse> createBlockQueryResponse(
260  std::string error_message) const = 0;
261  };
262 
263  } // namespace interface
264 } // namespace shared_model
265 
266 #endif // IROHA_QUERY_RESPONSE_FACTORY_HPP
Definition: hash.hpp:18
std::string ErrorMessageType
Message type.
Definition: error_query_response.hpp:54
std::string DomainIdType
Iroha domain id type.
Definition: types.hpp:56
Definition: permissions.hpp:103
Definition: amount.hpp:19
Definition: query_response_factory.hpp:39
Provides query metadata for account detail list pagination.
Definition: account_detail_record_id.hpp:17
std::string DetailType
Type of detail.
Definition: types.hpp:75
std::string AccountIdType
Type of account id.
Definition: types.hpp:38
ErrorQueryType
Definition: query_response_factory.hpp:110
uint8_t PrecisionType
Type of precision.
Definition: types.hpp:46
uint32_t ErrorCodeType
Error code type.
Definition: error_query_response.hpp:62
uint16_t TransactionsNumberType
Type of a number of transactions in block and query response page.
Definition: types.hpp:84
std::vector< std::shared_ptr< shared_model::interface::Peer > > PeerList
Type of peers collection.
Definition: types.hpp:93
Definition: command_executor.hpp:12
uint16_t QuorumType
Type of Quorum used in transaction and set quorum.
Definition: types.hpp:65
std::string JsonType
Type of JSON data.
Definition: types.hpp:77
std::string AssetIdType
Type of asset id.
Definition: types.hpp:58