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 <boost/optional/optional_fwd.hpp>
10 #include <cstdint>
11 #include <functional>
12 #include <memory>
13 
14 #include "common/result_fwd.hpp"
16 
17 namespace iroha {
18  namespace ametsuchi {
19 
23  class BlockStorage {
24  public:
29  virtual bool insert(
30  std::shared_ptr<const shared_model::interface::Block> block) = 0;
31 
36  virtual boost::optional<std::unique_ptr<shared_model::interface::Block>>
38 
42  virtual size_t size() const = 0;
43 
47  virtual void reload() = 0;
48 
52  virtual void clear() = 0;
53 
55  using FunctionType = std::function<expected::Result<void, std::string>(
56  std::shared_ptr<const shared_model::interface::Block>)>;
57 
62  FunctionType function) const = 0;
63 
64  virtual ~BlockStorage() = default;
65  };
66 
67  } // namespace ametsuchi
68 } // namespace iroha
69 
70 #endif // IROHA_BLOCK_STORAGE_HPP
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:48
virtual ~BlockStorage()=default
std::function< expected::Result< void, std::string >(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:56
Definition: block_storage.hpp:23
Definition: result_fwd.hpp:27
virtual size_t size() const =0
Definition: block_query.hpp:15
virtual expected::Result< void, std::string > forEach(FunctionType function) const =0
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