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 "common/result.hpp"
16 #include "logger/logger_fwd.hpp"
18 
19 namespace iroha::ametsuchi {
20 
21  class BlockIndex;
22  class PeerQuery;
23  class CommandExecutor;
24  class WsvCommand;
25  class TransactionExecutor;
26 
28  friend class StorageImpl;
29 
30  public:
32  boost::optional<std::shared_ptr<const iroha::LedgerState>> ledger_state,
33  std::unique_ptr<WsvCommand> wsv_command,
34  std::unique_ptr<PeerQuery> peer_query,
35  std::unique_ptr<BlockIndex> block_index,
36  std::shared_ptr<CommandExecutor> command_executor,
37  std::unique_ptr<BlockStorage> block_storage,
38  logger::LoggerManagerTreePtr log_manager);
39 
40  bool apply(
41  std::shared_ptr<const shared_model::interface::Block> block) override;
42 
43  bool applyIf(std::shared_ptr<const shared_model::interface::Block> block,
44  MutableStoragePredicate predicate) override;
45 
46  boost::optional<std::shared_ptr<const iroha::LedgerState>> getLedgerState()
47  const;
48 
50  BlockStorage &block_storage)
51  && override;
52 
53  ~MutableStorageImpl() override;
54 
55  private:
61  template <typename Function>
62  bool withSavepoint(Function &&function);
63 
68  bool applyBlockIf(
69  std::shared_ptr<const shared_model::interface::Block> block,
70  MutableStoragePredicate predicate);
71 
72  boost::optional<std::shared_ptr<const iroha::LedgerState>> ledger_state_;
73 
74  DatabaseTransaction &db_tx_;
75  std::unique_ptr<WsvCommand> wsv_command_;
76  std::unique_ptr<PeerQuery> peer_query_;
77  std::unique_ptr<BlockIndex> block_index_;
78  std::shared_ptr<TransactionExecutor> transaction_executor_;
79  std::unique_ptr<BlockStorage> block_storage_;
80 
81  bool committed;
82 
83  logger::LoggerPtr log_;
84  };
85 
86 } // namespace iroha::ametsuchi
87 
88 #endif // IROHA_MUTABLE_STORAGE_IMPL_HPP
Definition: block_query.hpp:17
Definition: block_storage.hpp:23
bool applyIf(std::shared_ptr< const shared_model::interface::Block > block, MutableStoragePredicate predicate) override
Definition: mutable_storage_impl.cpp:120
Definition: result_fwd.hpp:27
bool apply(std::shared_ptr< const shared_model::interface::Block > block) override
Definition: mutable_storage_impl.cpp:112
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:127
MutableStorageImpl(boost::optional< std::shared_ptr< const iroha::LedgerState >> ledger_state, std::unique_ptr< WsvCommand > wsv_command, std::unique_ptr< PeerQuery > peer_query, std::unique_ptr< BlockIndex > block_index, std::shared_ptr< CommandExecutor > command_executor, std::unique_ptr< BlockStorage > block_storage, logger::LoggerManagerTreePtr log_manager)
Definition: mutable_storage_impl.cpp:27
std::function< bool(std::shared_ptr< const shared_model::interface::Block >, const LedgerState &)> MutableStoragePredicate
Definition: mutable_storage.hpp:43
~MutableStorageImpl() override
Definition: mutable_storage_impl.cpp:160
Definition: mutable_storage.hpp:33
std::shared_ptr< LoggerManagerTree > LoggerManagerTreePtr
Definition: logger_manager_fwd.hpp:14
Definition: db_transaction.hpp:13
Definition: mutable_storage_impl.hpp:27
Definition: storage_impl.hpp:28
expected::Result< CommitResult, std::string > commit(BlockStorage &block_storage) &&override
Definition: mutable_storage_impl.cpp:132