Kagome
Polkadot Runtime Engine in C++17
chain.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_CONSENSUS_GRANDPA_CHAIN_HPP
7 #define KAGOME_CORE_CONSENSUS_GRANDPA_CHAIN_HPP
8 
9 #include <vector>
10 
11 #include <optional>
12 #include <outcome/outcome.hpp>
15 
17 
21  struct Chain {
22  virtual ~Chain() = default;
23 
28  virtual outcome::result<bool> hasBlock(
29  const primitives::BlockHash &block) const = 0;
30 
36  virtual outcome::result<std::vector<primitives::BlockHash>> getAncestry(
37  const primitives::BlockHash &base,
38  const primitives::BlockHash &block) const = 0;
39 
46  virtual bool hasAncestry(const primitives::BlockHash &base,
47  const primitives::BlockHash &block) const = 0;
48 
54  virtual outcome::result<BlockInfo> bestChainContaining(
55  const primitives::BlockHash &base,
56  std::optional<VoterSetId> voter_set_id) const = 0;
57 
62  inline bool isEqualOrDescendOf(const primitives::BlockHash &base,
63  const primitives::BlockHash &block) const {
64  return base == block ? true : hasAncestry(base, block);
65  }
66  };
67 
68 } // namespace kagome::consensus::grandpa
69 
70 #endif // KAGOME_CORE_CONSENSUS_GRANDPA_CHAIN_HPP
virtual outcome::result< std::vector< primitives::BlockHash > > getAncestry(const primitives::BlockHash &base, const primitives::BlockHash &block) const =0
Get the ancestry of a {.
virtual outcome::result< bool > hasBlock(const primitives::BlockHash &block) const =0
Checks if {.
virtual bool hasAncestry(const primitives::BlockHash &base, const primitives::BlockHash &block) const =0
Check if block is ancestor for second one.
virtual outcome::result< BlockInfo > bestChainContaining(const primitives::BlockHash &base, std::optional< VoterSetId > voter_set_id) const =0
bool isEqualOrDescendOf(const primitives::BlockHash &base, const primitives::BlockHash &block) const
Definition: chain.hpp:62