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.hpp>
17 #include "common/result.hpp"
18 
19 namespace shared_model {
20  namespace interface {
21  class Block;
22  }
23 } // namespace shared_model
24 
25 namespace iroha {
26 
27  namespace ametsuchi {
28 
29  class BlockStorageFactory;
30  class BlockQuery;
31  class WsvQuery;
32 
37  class Storage : public TemporaryFactory,
38  public MutableFactory,
39  public PeerQueryFactory,
40  public BlockQueryFactory,
41  public QueryExecutorFactory {
42  public:
43  virtual std::shared_ptr<WsvQuery> getWsvQuery() const = 0;
44 
45  virtual std::shared_ptr<BlockQuery> getBlockQuery() const = 0;
46 
52  virtual bool insertBlock(
53  std::shared_ptr<const shared_model::interface::Block> block) = 0;
54 
59  virtual expected::Result<std::unique_ptr<CommandExecutor>, std::string>
60  createCommandExecutor() = 0;
61 
67  virtual expected::Result<void, std::string> insertPeer(
68  const shared_model::interface::Peer &peer) = 0;
69 
70  using MutableFactory::createMutableStorage;
71 
76  virtual std::unique_ptr<MutableStorage> createMutableStorage(
77  std::shared_ptr<CommandExecutor> command_executor,
78  BlockStorageFactory &storage_factory) = 0;
79 
84  virtual rxcpp::observable<
85  std::shared_ptr<const shared_model::interface::Block>>
86  on_commit() = 0;
87 
91  virtual void reset() = 0;
92 
93  /*
94  * Remove all records from the tables
95  * @return error message if reset has failed
96  */
97  virtual expected::Result<void, std::string> resetWsv() = 0;
98 
102  virtual void resetPeers() = 0;
103 
109  virtual void dropStorage() = 0;
110 
111  virtual void freeConnections() = 0;
112 
113  virtual ~Storage() = default;
114  };
115 
116  } // namespace ametsuchi
117 
118 } // namespace iroha
119 
120 #endif // IROHA_AMETSUCHI_H
Definition: temporary_factory.hpp:18
Definition: peer.hpp:18
Definition: block_query_factory.hpp:15
Definition: storage.hpp:37
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