hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
storage.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_AMETSUCHI_H
7 #define IROHA_AMETSUCHI_H
8 
9 #include <vector>
10 
11 #include <rxcpp/rx-observable-fwd.hpp>
18 #include "common/result_fwd.hpp"
19 
20 namespace shared_model {
21  namespace interface {
22  class Block;
23  }
24 } // namespace shared_model
25 
26 namespace iroha {
27 
28  namespace ametsuchi {
29 
30  class BlockStorageFactory;
31  class BlockQuery;
32  class WsvQuery;
33 
38  class Storage : public TemporaryFactory,
39  public MutableFactory,
40  public PeerQueryFactory,
41  public BlockQueryFactory,
42  public QueryExecutorFactory,
43  public SettingQueryFactory {
44  public:
45  virtual std::shared_ptr<WsvQuery> getWsvQuery() const = 0;
46 
47  virtual std::shared_ptr<BlockQuery> getBlockQuery() const = 0;
48 
54  virtual bool insertBlock(
55  std::shared_ptr<const shared_model::interface::Block> block) = 0;
56 
62  createCommandExecutor() = 0;
63 
69  virtual expected::Result<void, std::string> insertPeer(
70  const shared_model::interface::Peer &peer) = 0;
71 
72  using MutableFactory::createMutableStorage;
73 
78  virtual std::unique_ptr<MutableStorage> createMutableStorage(
79  std::shared_ptr<CommandExecutor> command_executor,
80  BlockStorageFactory &storage_factory) = 0;
81 
86  virtual rxcpp::observable<
87  std::shared_ptr<const shared_model::interface::Block>>
88  on_commit() = 0;
89 
93  virtual void resetPeers() = 0;
94 
98  virtual expected::Result<void, std::string> dropBlockStorage() = 0;
99 
100  virtual boost::optional<std::shared_ptr<const iroha::LedgerState>>
101  getLedgerState() const = 0;
102 
103  virtual void freeConnections() = 0;
104 
105  virtual ~Storage() = default;
106  };
107 
108  } // namespace ametsuchi
109 
110 } // namespace iroha
111 
112 #endif // IROHA_AMETSUCHI_H
Definition: temporary_factory.hpp:18
Definition: setting_query_factory.hpp:15
Definition: peer.hpp:20
Definition: result_fwd.hpp:27
Definition: block_query_factory.hpp:15
Definition: storage.hpp:38
Definition: query_executor_factory.hpp:18
Definition: block_query.hpp:15
Definition: peer_query_factory.hpp:15
Definition: block_storage_factory.hpp:18
Definition: command_executor.hpp:12
Definition: mutable_factory.hpp:27