Kagome
Polkadot Runtime Engine in C++17
blocks_request.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_BLOCKS_REQUEST_HPP
7 #define KAGOME_BLOCKS_REQUEST_HPP
8 
9 #include <cstdint>
10 
11 #include <gsl/span>
12 #include <optional>
13 
16 #include "primitives/block_id.hpp"
17 #include "primitives/common.hpp"
18 
19 namespace kagome::network {
23  struct BlocksRequest {
32  std::optional<uint32_t> max{};
33 
35  static constexpr BlockAttributes kBasicAttributes =
38 
39  bool attributeIsSet(const BlockAttribute &attribute) const {
40  return fields & attribute;
41  }
42 
43  using Fingerprint = size_t;
44 
45  inline Fingerprint fingerprint() const;
46  };
47 } // namespace kagome::network
48 
49 template <>
50 struct std::hash<kagome::network::BlocksRequest> {
51  auto operator()(const kagome::network::BlocksRequest &blocks_request) const {
52  auto result =
54 
55  boost::hash_combine(
56  result, std::hash<kagome::primitives::BlockId>()(blocks_request.from));
57 
58  boost::hash_combine(
59  result,
60  std::hash<kagome::network::Direction>()(blocks_request.direction));
61 
62  boost::hash_combine(
63  result, std::hash<std::optional<uint32_t>>()(blocks_request.max));
64 
65  return result;
66  }
67 };
68 
71  return std::hash<BlocksRequest>()(*this);
72 }
73 
74 #endif // KAGOME_BLOCKS_REQUEST_HPP
Include a justification for the block.
bool attributeIsSet(const BlockAttribute &attribute) const
BlockAttributes fields
bits, showing, which parts of BlockData to return
auto operator()(const kagome::network::BlocksRequest &blocks_request) const
primitives::BlockId from
start from this block
boost::variant< BlockHash, BlockNumber > BlockId
Block id is the variant over BlockHash and BlockNumber.
Definition: block_id.hpp:18
Fingerprint fingerprint() const
std::optional< uint32_t > max
Direction direction
sequence direction
static constexpr BlockAttributes kBasicAttributes
includes HEADER, BODY and JUSTIFICATION