hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
flat_file_block_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_FLAT_FILE_BLOCK_STORAGE_HPP
7 #define IROHA_FLAT_FILE_BLOCK_STORAGE_HPP
8 
10 
13 #include "logger/logger_fwd.hpp"
14 
15 namespace iroha {
16  namespace ametsuchi {
18  public:
20  std::unique_ptr<FlatFile> flat_file,
21  std::shared_ptr<shared_model::interface::BlockJsonConverter>
22  json_converter,
23  logger::LoggerPtr log);
24 
25  ~FlatFileBlockStorage() override;
26 
27  bool insert(
28  std::shared_ptr<const shared_model::interface::Block> block) override;
29 
30  boost::optional<std::shared_ptr<const shared_model::interface::Block>>
32 
33  size_t size() const override;
34 
35  void clear() override;
36 
37  void forEach(FunctionType function) const override;
38 
39  private:
40  std::unique_ptr<FlatFile> flat_file_storage_;
41  std::shared_ptr<shared_model::interface::BlockJsonConverter>
42  json_converter_;
43  logger::LoggerPtr log_;
44  };
45  } // namespace ametsuchi
46 } // namespace iroha
47 
48 #endif // IROHA_FLAT_FILE_BLOCK_STORAGE_HPP
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:43
~FlatFileBlockStorage() override
Definition: flat_file_block_storage.cpp:24
Definition: block_storage.hpp:22
void forEach(FunctionType function) const override
Definition: flat_file_block_storage.cpp:73
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: flat_file_block_storage.hpp:17
Definition: block_query.hpp:14
bool insert(std::shared_ptr< const shared_model::interface::Block > block) override
Definition: flat_file_block_storage.cpp:29
FlatFileBlockStorage(std::unique_ptr< FlatFile > flat_file, std::shared_ptr< shared_model::interface::BlockJsonConverter > json_converter, logger::LoggerPtr log)
Definition: flat_file_block_storage.cpp:16
std::function< void(std::shared_ptr< const shared_model::interface::Block >)> FunctionType
type of function which can be applied to the elements of the storage
Definition: block_storage.hpp:51
void clear() override
Definition: flat_file_block_storage.cpp:69
size_t size() const override
Definition: flat_file_block_storage.cpp:65
boost::optional< std::shared_ptr< const shared_model::interface::Block > > fetch(shared_model::interface::types::HeightType height) const override
Definition: flat_file_block_storage.cpp:43