hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
flat_file.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_FLAT_FILE_HPP
7 #define IROHA_FLAT_FILE_HPP
8 
10 
11 #include <atomic>
12 #include <memory>
13 
14 #include "logger/logger.hpp"
15 
16 namespace iroha {
17  namespace ametsuchi {
18 
22  class FlatFile : public KeyValueStorage {
27  struct private_tag {};
28 
29  public:
30  // ----------| public API |----------
31 
32  static const uint32_t DIGIT_CAPACITY = 16;
33 
47 
53  static boost::optional<std::unique_ptr<FlatFile>> create(
54  const std::string &path);
55 
56  bool add(Identifier id, const Bytes &blob) override;
57 
58  boost::optional<Bytes> get(Identifier id) const override;
59 
60  std::string directory() const override;
61 
62  Identifier last_id() const override;
63 
71  static boost::optional<Identifier> check_consistency(
72  const std::string &dump_dir);
73 
74  void dropAll() override;
75 
76  // ----------| modify operations |----------
77 
78  FlatFile(const FlatFile &rhs) = delete;
79 
80  FlatFile(FlatFile &&rhs) = delete;
81 
82  FlatFile &operator=(const FlatFile &rhs) = delete;
83 
84  FlatFile &operator=(FlatFile &&rhs) = delete;
85 
86  // ----------| private API |----------
87 
95  const std::string &path,
96  FlatFile::private_tag,
97  logger::Logger log = logger::log("FlatFile"));
98 
99  private:
100  // ----------| private fields |----------
101 
105  std::atomic<Identifier> current_id_;
106 
110  const std::string dump_dir_;
111 
112  logger::Logger log_;
113 
114  public:
115  ~FlatFile() = default;
116  };
117  } // namespace ametsuchi
118 } // namespace iroha
119 #endif // IROHA_FLAT_FILE_HPP
FlatFile(const FlatFile &rhs)=delete
static std::string id_to_name(Identifier id)
Definition: flat_file.cpp:23
Identifier last_id() const override
Definition: flat_file.cpp:102
Definition: flat_file.hpp:22
string(REPLACE".""/"CMAKE_SWIG_OUTDIR ${SWIG_JAVA_PKG}) else() set(CMAKE_SWIG_FLAGS"") endif() myswig_add_library(irohajava LANGUAGE java SOURCES bindings.i) unset(CMAKE_SWIG_FLAGS) swig_link_libraries(irohajava $
Definition: CMakeLists.txt:54
static boost::optional< Identifier > check_consistency(const std::string &dump_dir)
Definition: flat_file.cpp:122
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
std::vector< uint8_t > Bytes
Definition: key_value_storage.hpp:26
static boost::optional< std::unique_ptr< FlatFile > > create(const std::string &path)
Definition: flat_file.cpp:29
Definition: block_query.hpp:16
FlatFile & operator=(const FlatFile &rhs)=delete
FlatFile::Identifier Identifier
Definition: flat_file.cpp:19
std::string directory() const override
Definition: flat_file.cpp:98
Logger log(const std::string &tag)
Definition: logger.cpp:48
bool add(Identifier id, const Bytes &blob) override
Definition: flat_file.cpp:44
static const uint32_t DIGIT_CAPACITY
Definition: flat_file.hpp:32
void dropAll() override
Definition: flat_file.cpp:106
Definition: key_value_storage.hpp:20