hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
mutable_storage_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_MUTABLE_STORAGE_IMPL_HPP
7 #define IROHA_MUTABLE_STORAGE_IMPL_HPP
8 
10 
11 #include <soci/soci.h>
13 #include "common/result.hpp"
15 #include "logger/logger_fwd.hpp"
17 
18 namespace iroha {
19  namespace ametsuchi {
20  class BlockIndex;
21  class PeerQuery;
22  class PostgresCommandExecutor;
23  class PostgresWsvCommand;
24  class TransactionExecutor;
25 
27  friend class StorageImpl;
28 
29  public:
31  boost::optional<std::shared_ptr<const iroha::LedgerState>>
32  ledger_state,
33  std::shared_ptr<PostgresCommandExecutor> command_executor,
34  std::unique_ptr<BlockStorage> block_storage,
35  logger::LoggerManagerTreePtr log_manager);
36 
37  bool apply(
38  std::shared_ptr<const shared_model::interface::Block> block) override;
39 
40  bool apply(rxcpp::observable<
41  std::shared_ptr<shared_model::interface::Block>> blocks,
42  MutableStoragePredicate predicate) override;
43 
44  boost::optional<std::shared_ptr<const iroha::LedgerState>>
45  getLedgerState() const;
46 
48 
49  ~MutableStorageImpl() override;
50 
51  private:
57  template <typename Function>
58  bool withSavepoint(Function &&function);
59 
64  bool apply(std::shared_ptr<const shared_model::interface::Block> block,
65  MutableStoragePredicate predicate);
66 
67  boost::optional<std::shared_ptr<const iroha::LedgerState>> ledger_state_;
68 
69  soci::session &sql_;
70  std::unique_ptr<PostgresWsvCommand> wsv_command_;
71  std::unique_ptr<PeerQuery> peer_query_;
72  std::unique_ptr<BlockIndex> block_index_;
73  std::shared_ptr<TransactionExecutor> transaction_executor_;
74  std::unique_ptr<BlockStorage> block_storage_;
75 
76  bool committed;
77 
78  logger::LoggerPtr log_;
79  };
80  } // namespace ametsuchi
81 } // namespace iroha
82 
83 #endif // IROHA_MUTABLE_STORAGE_IMPL_HPP
Definition: result_fwd.hpp:27
bool apply(std::shared_ptr< const shared_model::interface::Block > block) override
Definition: mutable_storage_impl.cpp:114
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
boost::optional< std::shared_ptr< const iroha::LedgerState > > getLedgerState() const
Definition: mutable_storage_impl.cpp:134
std::function< bool(std::shared_ptr< const shared_model::interface::Block >, const LedgerState &)> MutableStoragePredicate
Definition: mutable_storage.hpp:44
~MutableStorageImpl() override
Definition: mutable_storage_impl.cpp:158
Definition: block_query.hpp:15
Definition: mutable_storage.hpp:34
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
Definition: mutable_storage_impl.hpp:26
expected::Result< CommitResult, std::string > commit() &&override
Apply the local changes made to this MutableStorage to the global WSV.
Definition: mutable_storage_impl.cpp:139
MutableStorageImpl(boost::optional< std::shared_ptr< const iroha::LedgerState >> ledger_state, std::shared_ptr< PostgresCommandExecutor > command_executor, std::unique_ptr< BlockStorage > block_storage, logger::LoggerManagerTreePtr log_manager)
Definition: mutable_storage_impl.cpp:27
Definition: storage_impl.hpp:41