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>
15 #include "logger/logger_fwd.hpp"
17 
18 namespace iroha {
19  namespace ametsuchi {
20  class BlockIndex;
21  class PeerQuery;
22  class TransactionExecutor;
23 
25  friend class StorageImpl;
26 
27  public:
29  boost::optional<std::shared_ptr<const iroha::LedgerState>>
30  ledger_state,
31  std::shared_ptr<TransactionExecutor> transaction_executor,
32  std::unique_ptr<soci::session> sql,
33  std::shared_ptr<shared_model::interface::CommonObjectsFactory>
34  factory,
35  std::unique_ptr<BlockStorage> block_storage,
36  logger::LoggerManagerTreePtr log_manager);
37 
38  bool apply(
39  std::shared_ptr<const shared_model::interface::Block> block) override;
40 
41  bool apply(rxcpp::observable<
42  std::shared_ptr<shared_model::interface::Block>> blocks,
43  MutableStoragePredicate predicate) override;
44 
45  boost::optional<std::shared_ptr<const iroha::LedgerState>>
46  getLedgerState() const;
47 
48  ~MutableStorageImpl() override;
49 
50  private:
56  template <typename Function>
57  bool withSavepoint(Function &&function);
58 
63  bool apply(std::shared_ptr<const shared_model::interface::Block> block,
64  MutableStoragePredicate predicate);
65 
66  boost::optional<std::shared_ptr<const iroha::LedgerState>> ledger_state_;
67 
68  std::unique_ptr<soci::session> sql_;
69  std::unique_ptr<PeerQuery> peer_query_;
70  std::unique_ptr<BlockIndex> block_index_;
71  std::shared_ptr<TransactionExecutor> transaction_executor_;
72  std::unique_ptr<BlockStorage> block_storage_;
73 
74  bool committed;
75 
76  logger::LoggerPtr log_;
77  };
78  } // namespace ametsuchi
79 } // namespace iroha
80 
81 #endif // IROHA_MUTABLE_STORAGE_IMPL_HPP
MutableStorageImpl(boost::optional< std::shared_ptr< const iroha::LedgerState >> ledger_state, std::shared_ptr< TransactionExecutor > transaction_executor, std::unique_ptr< soci::session > sql, std::shared_ptr< shared_model::interface::CommonObjectsFactory > factory, std::unique_ptr< BlockStorage > block_storage, logger::LoggerManagerTreePtr log_manager)
Definition: mutable_storage_impl.cpp:23
boost::optional< std::shared_ptr< const iroha::LedgerState > > getLedgerState() const
Definition: mutable_storage_impl.cpp:119
bool apply(std::shared_ptr< const shared_model::interface::Block > block) override
Definition: mutable_storage_impl.cpp:99
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
std::function< bool(std::shared_ptr< const shared_model::interface::Block >, const LedgerState &)> MutableStoragePredicate
Definition: mutable_storage.hpp:40
~MutableStorageImpl() override
Definition: mutable_storage_impl.cpp:123
Definition: block_query.hpp:14
Definition: mutable_storage.hpp:30
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
Definition: mutable_storage_impl.hpp:24
Definition: storage_impl.hpp:41