hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
postgres_command_executor.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_POSTGRES_COMMAND_EXECUTOR_HPP
7 #define IROHA_POSTGRES_COMMAND_EXECUTOR_HPP
8 
9 #include <optional>
11 
13 
14 namespace soci {
15  class session;
16 }
17 
18 namespace shared_model {
19  namespace interface {
20  class AddAssetQuantity;
21  class AddPeer;
22  class AddSignatory;
23  class AppendRole;
24  class CompareAndSetAccountDetail;
25  class CallEngine;
26  class CallModel;
27  class CreateAccount;
28  class CreateAsset;
29  class CreateDomain;
30  class CreateRole;
31  class DetachRole;
32  class GrantPermission;
33  class PermissionToString;
34  class RemovePeer;
35  class RemoveSignatory;
36  class RevokePermission;
37  class SetAccountDetail;
38  class SetQuorum;
39  class SubtractAssetQuantity;
40  class TransferAsset;
41  class SetSettingValue;
42  } // namespace interface
43 } // namespace shared_model
44 
45 namespace iroha {
46  namespace ametsuchi {
47 
48  class PostgresSpecificQueryExecutor;
49  class VmCaller;
50 
52  public:
54  std::unique_ptr<soci::session> sql,
55  std::shared_ptr<shared_model::interface::PermissionToString>
56  perm_converter,
57  std::shared_ptr<PostgresSpecificQueryExecutor>
58  specific_query_executor,
59  std::optional<std::reference_wrapper<const VmCaller>> vm_caller);
60 
62 
66  &creator_account_id,
67  const std::string &tx_hash,
69  bool do_validation) override;
70 
71  soci::session &getSession();
72 
73  CommandResult operator()(
76  &creator_account_id,
77  const std::string &tx_hash,
79  bool do_validation);
80 
81  CommandResult operator()(
82  const shared_model::interface::AddPeer &command,
84  &creator_account_id,
85  const std::string &tx_hash,
87  bool do_validation);
88 
89  CommandResult operator()(
92  &creator_account_id,
93  const std::string &tx_hash,
95  bool do_validation);
96 
97  CommandResult operator()(
100  &creator_account_id,
101  const std::string &tx_hash,
103  bool do_validation);
104 
105  CommandResult operator()(
108  &creator_account_id,
109  const std::string &tx_hash,
111  bool do_validation);
112 
113  CommandResult operator()(
116  &creator_account_id,
117  const std::string &tx_hash,
119  bool do_validation);
120 
121  CommandResult operator()(
124  &creator_account_id,
125  const std::string &tx_hash,
127  bool do_validation);
128 
129  CommandResult operator()(
132  &creator_account_id,
133  const std::string &tx_hash,
135  bool do_validation);
136 
137  CommandResult operator()(
140  &creator_account_id,
141  const std::string &tx_hash,
143  bool do_validation);
144 
145  CommandResult operator()(
148  &creator_account_id,
149  const std::string &tx_hash,
151  bool do_validation);
152 
153  CommandResult operator()(
156  &creator_account_id,
157  const std::string &tx_hash,
159  bool do_validation);
160 
161  CommandResult operator()(
164  &creator_account_id,
165  const std::string &tx_hash,
167  bool do_validation);
168 
169  CommandResult operator()(
172  &creator_account_id,
173  const std::string &tx_hash,
175  bool do_validation);
176 
177  CommandResult operator()(
180  &creator_account_id,
181  const std::string &tx_hash,
183  bool do_validation);
184 
185  CommandResult operator()(
188  &creator_account_id,
189  const std::string &tx_hash,
191  bool do_validation);
192 
193  CommandResult operator()(
196  &creator_account_id,
197  const std::string &tx_hash,
199  bool do_validation);
200 
201  CommandResult operator()(
202  const shared_model::interface::SetQuorum &command,
204  &creator_account_id,
205  const std::string &tx_hash,
207  bool do_validation);
208 
209  CommandResult operator()(
212  &creator_account_id,
213  const std::string &tx_hash,
215  bool do_validation);
216 
217  CommandResult operator()(
220  &creator_account_id,
221  const std::string &tx_hash,
223  bool do_validation);
224 
225  CommandResult operator()(
228  &creator_account_id,
229  const std::string &,
231  bool do_validation);
232 
233  CommandResult operator()(
234  const shared_model::interface::CallModel &command,
236  &creator_account_id,
237  const std::string &tx_hash,
239  bool do_validation);
240 
241  private:
242  class CommandStatements;
243  class StatementExecutor;
244 
245  void initStatements();
246 
247  std::unique_ptr<CommandStatements> makeCommandStatements(
248  const std::unique_ptr<soci::session> &session,
249  const std::string &base_statement,
250  const std::vector<std::string> &permission_checks);
251 
252  std::unique_ptr<soci::session> sql_;
253 
254  std::shared_ptr<shared_model::interface::PermissionToString>
255  perm_converter_;
256  std::shared_ptr<PostgresSpecificQueryExecutor> specific_query_executor_;
257  std::optional<std::reference_wrapper<const VmCaller>> vm_caller_;
258 
259  std::unique_ptr<CommandStatements> add_asset_quantity_statements_;
260  std::unique_ptr<CommandStatements> add_peer_statements_;
261  std::unique_ptr<CommandStatements> add_signatory_statements_;
262  std::unique_ptr<CommandStatements> append_role_statements_;
263  std::unique_ptr<CommandStatements>
264  compare_and_set_account_detail_statements_;
265  std::unique_ptr<CommandStatements> create_account_statements_;
266  std::unique_ptr<CommandStatements> create_asset_statements_;
267  std::unique_ptr<CommandStatements> create_domain_statements_;
268  std::unique_ptr<CommandStatements> create_role_statements_;
269  std::unique_ptr<CommandStatements> detach_role_statements_;
270  std::unique_ptr<CommandStatements> grant_permission_statements_;
271  std::unique_ptr<CommandStatements> remove_peer_statements_;
272  std::unique_ptr<CommandStatements> remove_signatory_statements_;
273  std::unique_ptr<CommandStatements> revoke_permission_statements_;
274  std::unique_ptr<CommandStatements> set_account_detail_statements_;
275  std::unique_ptr<CommandStatements> set_quorum_statements_;
276  std::unique_ptr<CommandStatements> store_engine_response_statements_;
277  std::unique_ptr<CommandStatements> subtract_asset_quantity_statements_;
278  std::unique_ptr<CommandStatements> transfer_asset_statements_;
279  std::unique_ptr<CommandStatements> set_setting_value_statements_;
280  };
281  } // namespace ametsuchi
282 } // namespace iroha
283 
284 #endif // IROHA_POSTGRES_COMMAND_EXECUTOR_HPP
Definition: compare_and_set_account_detail.hpp:21
Definition: add_signatory.hpp:19
Definition: set_quorum.hpp:18
Definition: subtract_asset_quantity.hpp:20
Definition: set_setting_value.hpp:19
Definition: result_fwd.hpp:27
Definition: postgres_command_executor.cpp:388
Definition: detach_role.hpp:19
Definition: remove_signatory.hpp:18
Definition: create_asset.hpp:18
Definition: postgres_command_executor.cpp:349
Definition: call_engine.hpp:20
Definition: remove_peer.hpp:19
Definition: append_role.hpp:19
Definition: transfer_asset.hpp:19
Definition: block_query.hpp:15
Definition: postgres_command_executor.hpp:51
std::string AccountIdType
Type of account id.
Definition: types.hpp:38
Definition: command_executor.hpp:43
Definition: create_domain.hpp:18
Definition: create_account.hpp:19
Definition: call_model.hpp:13
WsvCommandResult execute(soci::statement &st, Function &&error)
Definition: postgres_wsv_command.cpp:26
Definition: grant_permission.hpp:19
Definition: set_account_detail.hpp:19
Definition: revoke_permission.hpp:19
Definition: command.hpp:42
int32_t CommandIndexType
Type of command index within a transaction.
Definition: types.hpp:97
Definition: add_asset_quantity.hpp:20
Definition: create_role.hpp:19
Definition: command_executor.hpp:12
Definition: pool_wrapper.hpp:11
Definition: add_peer.hpp:20