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  BlockStorage &block_storage)
49  && override;
50 
51  ~MutableStorageImpl() override;
52 
53  private:
59  template <typename Function>
60  bool withSavepoint(Function &&function);
61 
66  bool apply(std::shared_ptr<const shared_model::interface::Block> block,
67  MutableStoragePredicate predicate);
68 
69  boost::optional<std::shared_ptr<const iroha::LedgerState>> ledger_state_;
70 
71  soci::session &sql_;
72  std::unique_ptr<PostgresWsvCommand> wsv_command_;
73  std::unique_ptr<PeerQuery> peer_query_;
74  std::unique_ptr<BlockIndex> block_index_;
75  std::shared_ptr<TransactionExecutor> transaction_executor_;
76  std::unique_ptr<BlockStorage> block_storage_;
77 
78  bool committed;
79 
80  logger::LoggerPtr log_;
81  };
82  } // namespace ametsuchi
83 } // namespace iroha
84 
85 #endif // IROHA_MUTABLE_STORAGE_IMPL_HPP
Definition: block_storage.hpp:23
Definition: result_fwd.hpp:27
bool apply(std::shared_ptr< const shared_model::interface::Block > block) override
Definition: mutable_storage_impl.cpp:115
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:141
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:176
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
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:28
Definition: storage_impl.hpp:41
expected::Result< CommitResult, std::string > commit(BlockStorage &block_storage) &&override
Definition: mutable_storage_impl.cpp:146