hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
mutable_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_MUTABLE_STORAGE_HPP
7 #define IROHA_MUTABLE_STORAGE_HPP
8 
9 #include <functional>
10 
13 #include "common/result.hpp"
15 
16 namespace shared_model {
17  namespace interface {
18  class Block;
19  } // namespace interface
20 } // namespace shared_model
21 
22 namespace iroha {
23  struct LedgerState;
24 
25  namespace ametsuchi {
26 
27  class WsvQuery;
28 
34  public:
41  using MutableStoragePredicate = std::function<bool(
42  std::shared_ptr<const shared_model::interface::Block>,
43  const LedgerState &)>;
44 
45  struct CommitResult {
46  std::shared_ptr<const LedgerState> ledger_state;
47  std::unique_ptr<BlockStorage> block_storage;
48  };
49 
54  virtual bool apply(
55  std::shared_ptr<const shared_model::interface::Block> block) = 0;
56 
65  virtual bool applyIf(
66  std::shared_ptr<const shared_model::interface::Block> block,
67  MutableStoragePredicate predicate) = 0;
68 
72  commit(BlockStorage &block_storage) && = 0;
73 
74  virtual ~MutableStorage() = default;
75  };
76 
77  } // namespace ametsuchi
78 } // namespace iroha
79 
80 #endif // IROHA_MUTABLE_STORAGE_HPP
Definition: block_query.hpp:17
decltype(auto) constexpr apply(Tuple &&t, F &&f)
apply F to Tuple
Definition: soci_utils.hpp:72
Definition: block_storage.hpp:23
Definition: result_fwd.hpp:27
Definition: mutable_storage.hpp:45
std::function< bool(std::shared_ptr< const shared_model::interface::Block >, const LedgerState &)> MutableStoragePredicate
Definition: mutable_storage.hpp:43
Definition: block_query.hpp:15
Definition: mutable_storage.hpp:33
std::shared_ptr< const LedgerState > ledger_state
Definition: mutable_storage.hpp:46
Definition: ledger_state.hpp:25
Definition: command_executor.hpp:13
std::unique_ptr< BlockStorage > block_storage
Definition: mutable_storage.hpp:47