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>
21 
22 namespace shared_model {
23  namespace crypto {
24  class Hash;
25  }
26  namespace interface {
27  class Block;
28  class Amount;
29  } // namespace interface
30 } // namespace shared_model
31 
32 namespace shared_model {
33  namespace interface {
34 
39  public:
40  virtual ~QueryResponseFactory() = default;
41 
52  virtual std::unique_ptr<QueryResponse> createAccountAssetResponse(
53  std::vector<std::tuple<types::AccountIdType,
56  size_t total_assets_number,
57  std::optional<shared_model::interface::types::AssetIdType>
58  next_asset_id,
59  const crypto::Hash &query_hash) const = 0;
60 
70  virtual std::unique_ptr<QueryResponse> createAccountDetailResponse(
71  types::DetailType account_detail,
72  size_t total_number,
73  std::optional<std::reference_wrapper<
75  next_record_id,
76  const crypto::Hash &query_hash) const = 0;
77 
88  virtual std::unique_ptr<QueryResponse> createAccountResponse(
93  std::vector<std::string> roles,
94  const crypto::Hash &query_hash) const = 0;
95 
102  virtual std::unique_ptr<QueryResponse> createBlockResponse(
103  std::unique_ptr<Block> block,
104  const crypto::Hash &query_hash) const = 0;
105 
109  enum class ErrorQueryType {
110  kStatelessFailed,
111  kStatefulFailed,
112  kNoAccount,
113  kNoAccountAssets,
114  kNoAccountDetail,
115  kNoSignatories,
116  kNotSupported,
117  kNoAsset,
118  kNoRoles
119  };
128  virtual std::unique_ptr<QueryResponse> createErrorQueryResponse(
129  ErrorQueryType error_type,
132  const crypto::Hash &query_hash) const = 0;
133 
140  virtual std::unique_ptr<QueryResponse> createSignatoriesResponse(
141  std::vector<types::PubkeyType> signatories,
142  const crypto::Hash &query_hash) const = 0;
143 
150  virtual std::unique_ptr<QueryResponse> createTransactionsResponse(
151  std::vector<std::unique_ptr<shared_model::interface::Transaction>>
152  transactions,
153  const crypto::Hash &query_hash) const = 0;
154 
165  virtual std::unique_ptr<QueryResponse> createTransactionsPageResponse(
166  std::vector<std::unique_ptr<shared_model::interface::Transaction>>
167  transactions,
168  std::optional<std::reference_wrapper<const crypto::Hash>>
169  next_tx_hash,
170  interface::types::TransactionsNumberType all_transactions_size,
171  const crypto::Hash &query_hash) const = 0;
172 
182  virtual std::unique_ptr<QueryResponse>
183  createPendingTransactionsPageResponse(
184  std::vector<std::unique_ptr<interface::Transaction>> transactions,
185  interface::types::TransactionsNumberType all_transactions_size,
186  std::optional<interface::PendingTransactionsPageResponse::BatchInfo>
187  next_batch_info,
188  const crypto::Hash &query_hash) const = 0;
189 
199  virtual std::unique_ptr<QueryResponse> createAssetResponse(
200  types::AssetIdType asset_id,
201  types::DomainIdType domain_id,
202  types::PrecisionType precision,
203  const crypto::Hash &query_hash) const = 0;
204 
211  virtual std::unique_ptr<QueryResponse> createRolesResponse(
212  std::vector<types::RoleIdType> roles,
213  const crypto::Hash &query_hash) const = 0;
214 
221  virtual std::unique_ptr<QueryResponse> createRolePermissionsResponse(
222  RolePermissionSet role_permissions,
223  const crypto::Hash &query_hash) const = 0;
224 
231  virtual std::unique_ptr<QueryResponse> createPeersResponse(
232  types::PeerList peers, const crypto::Hash &query_hash) const = 0;
233 
239  virtual std::unique_ptr<BlockQueryResponse> createBlockQueryResponse(
240  std::shared_ptr<const Block> block) const = 0;
241 
247  virtual std::unique_ptr<BlockQueryResponse> createBlockQueryResponse(
248  std::string error_message) const = 0;
249  };
250 
251  } // namespace interface
252 } // namespace shared_model
253 
254 #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:53
Definition: permissions.hpp:96
Definition: amount.hpp:19
Definition: query_response_factory.hpp:38
Provides query metadata for account detail list pagination.
Definition: account_detail_record_id.hpp:17
std::string DetailType
Type of detail.
Definition: types.hpp:72
std::string AccountIdType
Type of account id.
Definition: types.hpp:39
ErrorQueryType
Definition: query_response_factory.hpp:109
uint8_t PrecisionType
Type of precision.
Definition: types.hpp:41
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:81
std::vector< std::shared_ptr< shared_model::interface::Peer > > PeerList
Type of peers collection.
Definition: types.hpp:90
Definition: command_executor.hpp:12
uint16_t QuorumType
Type of Quorum used in transaction and set quorum.
Definition: types.hpp:62
std::string JsonType
Type of JSON data.
Definition: types.hpp:74
std::string AssetIdType
Type of asset id.
Definition: types.hpp:55