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<std::unique_ptr<shared_model::interface::Block>>
37 
41  virtual size_t size() const = 0;
42 
46  virtual void clear() = 0;
47 
49  using FunctionType = std::function<void(
50  std::shared_ptr<const shared_model::interface::Block>)>;
51 
55  virtual void forEach(FunctionType function) const = 0;
56 
57  virtual ~BlockStorage() = default;
58  };
59 
60  } // namespace ametsuchi
61 } // namespace iroha
62 
63 #endif // IROHA_BLOCK_STORAGE_HPP
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:48
virtual ~BlockStorage()=default
virtual void forEach(FunctionType function) const =0
Definition: block_storage.hpp:22
virtual size_t size() const =0
Definition: block_query.hpp:15
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:50
virtual boost::optional< std::unique_ptr< shared_model::interface::Block > > fetch(shared_model::interface::types::HeightType height) const =0
virtual bool insert(std::shared_ptr< const shared_model::interface::Block > block)=0