Kagome
Polkadot Runtime Engine in C++17
babe_digests_util.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_CONSENSUS_BABE_IMPL_BABE_DIGESTS_UTIL_HPP
7 #define KAGOME_CORE_CONSENSUS_BABE_IMPL_BABE_DIGESTS_UTIL_HPP
8 
9 #include <memory>
10 #include <optional>
11 
12 #include "common/visitor.hpp"
16 #include "outcome/outcome.hpp"
17 #include "primitives/block.hpp"
18 
19 namespace kagome::consensus {
20 
21  enum class DigestError {
26  };
27 
28  template <typename T, typename VarT>
29  std::optional<std::reference_wrapper<const std::decay_t<T>>> getFromVariant(
30  VarT &&v) {
31  return visit_in_place(
32  std::forward<VarT>(v),
33  [](const T &expected_val)
34  -> std::optional<std::reference_wrapper<const std::decay_t<T>>> {
35  return expected_val;
36  },
37  [](const auto &) { return std::nullopt; });
38  }
39 
40  outcome::result<std::pair<Seal, BabeBlockHeader>> getBabeDigests(
41  const primitives::BlockHeader &header);
42 
43  outcome::result<EpochDigest> getNextEpochDigest(
44  const primitives::BlockHeader &header);
45 
46 } // namespace kagome::consensus
47 
49 
50 #endif // KAGOME_CORE_CONSENSUS_BABE_IMPL_BABE_DIGESTS_UTIL_HPP
std::optional< std::reference_wrapper< const std::decay_t< T > > > getFromVariant(VarT &&v)
outcome::result< std::pair< Seal, BabeBlockHeader > > getBabeDigests(const primitives::BlockHeader &block_header)
outcome::result< EpochDigest > getNextEpochDigest(const primitives::BlockHeader &header)
OUTCOME_HPP_DECLARE_ERROR(kagome::api, JRpcServerImpl::Error)