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 
60  virtual expected::Result<void, std::string> insertPeer(
61  const shared_model::interface::Peer &peer) = 0;
62 
63  using MutableFactory::createMutableStorage;
64 
69  virtual expected::Result<std::unique_ptr<MutableStorage>, std::string>
70  createMutableStorage(BlockStorageFactory &storage_factory) = 0;
71 
76  virtual rxcpp::observable<
77  std::shared_ptr<const shared_model::interface::Block>>
78  on_commit() = 0;
79 
83  virtual void reset() = 0;
84 
85  /*
86  * Remove all records from the tables
87  * @return error message if reset has failed
88  */
89  virtual expected::Result<void, std::string> resetWsv() = 0;
90 
94  virtual void resetPeers() = 0;
95 
101  virtual void dropStorage() = 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:17
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:26