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>
14 #include "logger/logger_fwd.hpp"
16 
17 namespace iroha {
18  namespace ametsuchi {
19  class BlockIndex;
20  class PeerQuery;
21  class PostgresCommandExecutor;
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<PostgresCommandExecutor> command_executor,
32  std::unique_ptr<BlockStorage> block_storage,
33  logger::LoggerManagerTreePtr log_manager);
34 
35  bool apply(
36  std::shared_ptr<const shared_model::interface::Block> block) override;
37 
38  bool apply(rxcpp::observable<
39  std::shared_ptr<shared_model::interface::Block>> blocks,
40  MutableStoragePredicate predicate) override;
41 
42  boost::optional<std::shared_ptr<const iroha::LedgerState>>
43  getLedgerState() const;
44 
45  ~MutableStorageImpl() override;
46 
47  private:
53  template <typename Function>
54  bool withSavepoint(Function &&function);
55 
60  bool apply(std::shared_ptr<const shared_model::interface::Block> block,
61  MutableStoragePredicate predicate);
62 
63  boost::optional<std::shared_ptr<const iroha::LedgerState>> ledger_state_;
64 
65  soci::session &sql_;
66  std::unique_ptr<PeerQuery> peer_query_;
67  std::unique_ptr<BlockIndex> block_index_;
68  std::shared_ptr<TransactionExecutor> transaction_executor_;
69  std::unique_ptr<BlockStorage> block_storage_;
70 
71  bool committed;
72 
73  logger::LoggerPtr log_;
74  };
75  } // namespace ametsuchi
76 } // namespace iroha
77 
78 #endif // IROHA_MUTABLE_STORAGE_IMPL_HPP
boost::optional< std::shared_ptr< const iroha::LedgerState > > getLedgerState() const
Definition: mutable_storage_impl.cpp:125
bool apply(std::shared_ptr< const shared_model::interface::Block > block) override
Definition: mutable_storage_impl.cpp:105
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:129
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
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:26
Definition: storage_impl.hpp:39