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 <map>
12 
13 #include <soci/soci.h>
16 #include "logger/logger.hpp"
17 
18 namespace iroha {
19  namespace ametsuchi {
20  class BlockIndex;
21  class PostgresCommandExecutor;
22 
24  friend class StorageImpl;
25 
26  public:
29  std::shared_ptr<PostgresCommandExecutor> cmd_executor,
30  std::unique_ptr<soci::session> sql,
31  std::shared_ptr<shared_model::interface::CommonObjectsFactory>
32  factory,
33  logger::Logger log = logger::log("MutableStorage"));
34 
35  bool apply(const shared_model::interface::Block &block) override;
36 
37  bool apply(rxcpp::observable<
38  std::shared_ptr<shared_model::interface::Block>> blocks,
39  MutableStoragePredicate predicate) override;
40 
41  ~MutableStorageImpl() override;
42 
43  private:
49  template <typename Function>
50  bool withSavepoint(Function &&function);
51 
56  bool apply(const shared_model::interface::Block &block,
57  MutableStoragePredicate predicate);
58 
60  // ordered collection is used to enforce block insertion order in
61  // StorageImpl::commit
62  std::map<uint32_t, std::shared_ptr<shared_model::interface::Block>>
63  block_store_;
64 
65  std::unique_ptr<soci::session> sql_;
66  std::unique_ptr<PeerQuery> peer_query_;
67  std::unique_ptr<BlockIndex> block_index_;
68  std::shared_ptr<CommandExecutor> command_executor_;
69 
70  bool committed;
71 
72  logger::Logger log_;
73  };
74  } // namespace ametsuchi
75 } // namespace iroha
76 
77 #endif // IROHA_MUTABLE_STORAGE_IMPL_HPP
Definition: hash.hpp:18
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block.hpp:15
~MutableStorageImpl() override
Definition: mutable_storage_impl.cpp:117
Definition: block_query.hpp:16
Definition: mutable_storage.hpp:30
bool apply(const shared_model::interface::Block &block) override
Definition: mutable_storage_impl.cpp:97
Logger log(const std::string &tag)
Definition: logger.cpp:48
Definition: mutable_storage_impl.hpp:23
std::function< bool(const shared_model::interface::Block &, PeerQuery &, const shared_model::interface::types::HashType &)> MutableStoragePredicate
Definition: mutable_storage.hpp:42
MutableStorageImpl(shared_model::interface::types::HashType top_hash, std::shared_ptr< PostgresCommandExecutor > cmd_executor, std::unique_ptr< soci::session > sql, std::shared_ptr< shared_model::interface::CommonObjectsFactory > factory, logger::Logger log=logger::log("MutableStorage"))
Definition: mutable_storage_impl.cpp:20
Definition: storage_impl.hpp:36