hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
block_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_BLOCK_STORAGE_HPP
7 #define IROHA_BLOCK_STORAGE_HPP
8 
9 #include <cstdint>
10 #include <functional>
11 #include <memory>
12 
13 #include <boost/optional.hpp>
15 
16 namespace iroha {
17  namespace ametsuchi {
18 
22  class BlockStorage {
23  public:
28  virtual bool insert(
29  std::shared_ptr<const shared_model::interface::Block> block) = 0;
30 
35  virtual boost::optional<
36  std::shared_ptr<const shared_model::interface::Block>>
38 
42  virtual size_t size() const = 0;
43 
47  virtual void clear() = 0;
48 
50  using FunctionType = std::function<void(
51  std::shared_ptr<const shared_model::interface::Block>)>;
52 
56  virtual void forEach(FunctionType function) const = 0;
57 
58  virtual ~BlockStorage() = default;
59  };
60 
61  } // namespace ametsuchi
62 } // namespace iroha
63 
64 #endif // IROHA_BLOCK_STORAGE_HPP
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:43
virtual ~BlockStorage()=default
virtual void forEach(FunctionType function) const =0
Definition: block_storage.hpp:22
virtual boost::optional< std::shared_ptr< const shared_model::interface::Block > > fetch(shared_model::interface::types::HeightType height) const =0
virtual size_t size() const =0
Definition: block_query.hpp:14
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
virtual bool insert(std::shared_ptr< const shared_model::interface::Block > block)=0