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.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 
61  virtual expected::Result<std::unique_ptr<CommandExecutor>, std::string>
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 reset() = 0;
94 
95  /*
96  * Remove all records from the tables
97  * @return error message if reset has failed
98  */
99  virtual expected::Result<void, std::string> resetWsv() = 0;
100 
104  virtual void resetPeers() = 0;
105 
111  virtual void dropStorage() = 0;
112 
113  virtual void freeConnections() = 0;
114 
115  virtual ~Storage() = default;
116  };
117 
118  } // namespace ametsuchi
119 
120 } // namespace iroha
121 
122 #endif // IROHA_AMETSUCHI_H
Definition: temporary_factory.hpp:18
Definition: setting_query_factory.hpp:15
Definition: peer.hpp:20
Definition: block_query_factory.hpp:15
Definition: storage.hpp:38
Definition: query_executor_factory.hpp:17
Definition: block_query.hpp:14
Definition: peer_query_factory.hpp:15
Definition: block_storage_factory.hpp:18
Definition: command_executor.hpp:12
Definition: mutable_factory.hpp:27