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>
16 #include "logger/logger_fwd.hpp"
18 
19 namespace iroha {
20  namespace ametsuchi {
21  class BlockIndex;
22  class PostgresCommandExecutor;
23 
25  friend class StorageImpl;
26 
27  public:
31  std::shared_ptr<PostgresCommandExecutor> cmd_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 
46 
47  ~MutableStorageImpl() override;
48 
49  private:
55  template <typename Function>
56  bool withSavepoint(Function &&function);
57 
62  bool apply(std::shared_ptr<const shared_model::interface::Block> block,
63  MutableStoragePredicate predicate);
64 
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<CommandExecutor> command_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
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:39
Definition: hash.hpp:18
bool apply(std::shared_ptr< const shared_model::interface::Block > block) override
Definition: mutable_storage_impl.cpp:110
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
shared_model::interface::types::HeightType getTopBlockHeight() const
Definition: mutable_storage_impl.cpp:131
~MutableStorageImpl() override
Definition: mutable_storage_impl.cpp:135
MutableStorageImpl(shared_model::interface::types::HashType top_hash, shared_model::interface::types::HeightType top_height, std::shared_ptr< PostgresCommandExecutor > cmd_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:22
Definition: block_query.hpp:16
Definition: mutable_storage.hpp:30
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
Definition: mutable_storage_impl.hpp:24
std::function< bool(std::shared_ptr< const shared_model::interface::Block >, PeerQuery &, const shared_model::interface::types::HashType &)> MutableStoragePredicate
Definition: mutable_storage.hpp:43
Definition: storage_impl.hpp:37