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  bool insert(
26  std::shared_ptr<const shared_model::interface::Block> block) override;
27 
28  boost::optional<std::shared_ptr<const shared_model::interface::Block>>
30 
31  size_t size() const override;
32 
33  void clear() override;
34 
35  void forEach(FunctionType function) const override;
36 
37  private:
38  std::unique_ptr<FlatFile> flat_file_storage_;
39  std::shared_ptr<shared_model::interface::BlockJsonConverter>
40  json_converter_;
41  logger::LoggerPtr log_;
42  };
43  } // namespace ametsuchi
44 } // namespace iroha
45 
46 #endif // IROHA_FLAT_FILE_BLOCK_STORAGE_HPP
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:43
Definition: block_storage.hpp:22
void forEach(FunctionType function) const override
Definition: flat_file_block_storage.cpp:68
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:24
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:64
size_t size() const override
Definition: flat_file_block_storage.cpp:60
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:38