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>
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  boost::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,
74  &> next_record_id,
75  const crypto::Hash &query_hash) const = 0;
76 
87  virtual std::unique_ptr<QueryResponse> createAccountResponse(
92  std::vector<std::string> roles,
93  const crypto::Hash &query_hash) const = 0;
94 
101  virtual std::unique_ptr<QueryResponse> createBlockResponse(
102  std::unique_ptr<Block> block,
103  const crypto::Hash &query_hash) const = 0;
104 
108  enum class ErrorQueryType {
109  kStatelessFailed,
110  kStatefulFailed,
111  kNoAccount,
112  kNoAccountAssets,
113  kNoAccountDetail,
114  kNoSignatories,
115  kNotSupported,
116  kNoAsset,
117  kNoRoles
118  };
127  virtual std::unique_ptr<QueryResponse> createErrorQueryResponse(
128  ErrorQueryType error_type,
131  const crypto::Hash &query_hash) const = 0;
132 
139  virtual std::unique_ptr<QueryResponse> createSignatoriesResponse(
140  std::vector<types::PubkeyType> signatories,
141  const crypto::Hash &query_hash) const = 0;
142 
149  virtual std::unique_ptr<QueryResponse> createTransactionsResponse(
150  std::vector<std::unique_ptr<shared_model::interface::Transaction>>
151  transactions,
152  const crypto::Hash &query_hash) const = 0;
153 
164  virtual std::unique_ptr<QueryResponse> createTransactionsPageResponse(
165  std::vector<std::unique_ptr<shared_model::interface::Transaction>>
166  transactions,
167  boost::optional<const crypto::Hash &> next_tx_hash,
168  interface::types::TransactionsNumberType all_transactions_size,
169  const crypto::Hash &query_hash) const = 0;
170 
180  virtual std::unique_ptr<QueryResponse>
181  createPendingTransactionsPageResponse(
182  std::vector<std::unique_ptr<interface::Transaction>> transactions,
183  interface::types::TransactionsNumberType all_transactions_size,
184  boost::optional<interface::PendingTransactionsPageResponse::BatchInfo>
185  next_batch_info,
186  const crypto::Hash &query_hash) const = 0;
187 
197  virtual std::unique_ptr<QueryResponse> createAssetResponse(
198  types::AssetIdType asset_id,
199  types::DomainIdType domain_id,
200  types::PrecisionType precision,
201  const crypto::Hash &query_hash) const = 0;
202 
209  virtual std::unique_ptr<QueryResponse> createRolesResponse(
210  std::vector<types::RoleIdType> roles,
211  const crypto::Hash &query_hash) const = 0;
212 
219  virtual std::unique_ptr<QueryResponse> createRolePermissionsResponse(
220  RolePermissionSet role_permissions,
221  const crypto::Hash &query_hash) const = 0;
222 
229  virtual std::unique_ptr<QueryResponse> createPeersResponse(
230  types::PeerList peers, const crypto::Hash &query_hash) const = 0;
231 
237  virtual std::unique_ptr<BlockQueryResponse> createBlockQueryResponse(
238  std::shared_ptr<const Block> block) const = 0;
239 
245  virtual std::unique_ptr<BlockQueryResponse> createBlockQueryResponse(
246  std::string error_message) const = 0;
247  };
248 
249  } // namespace interface
250 } // namespace shared_model
251 
252 #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:108
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