Kagome
Polkadot Runtime Engine in C++17
scheduled_change.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_PRIMITIVES_SCHEDULED_CHANGE
7 #define KAGOME_CORE_PRIMITIVES_SCHEDULED_CHANGE
8 
10 #include "primitives/authority.hpp"
12 #include "primitives/common.hpp"
13 #include "scale/tie.hpp"
14 
15 namespace kagome::primitives {
16  struct DelayInChain {
17  SCALE_TIE(1);
18  uint32_t subchain_length = 0;
19 
20  DelayInChain() = default;
21  explicit DelayInChain(uint32_t delay) : subchain_length(delay) {}
22  virtual ~DelayInChain() = default;
23  };
24 
26  SCALE_TIE(2);
27  AuthorityList authorities{};
28  uint32_t subchain_length = 0;
29 
30  AuthorityListChange() = default;
31  AuthorityListChange(AuthorityList authorities, uint32_t delay)
32  : authorities(std::move(authorities)), subchain_length(delay) {}
33  virtual ~AuthorityListChange() = default;
34  };
35 
36  struct NextEpochData final : public consensus::EpochDigest {
37  using EpochDigest::EpochDigest;
38  };
39 
40  struct NextConfigDataV1 final {
41  SCALE_TIE(2);
42  std::pair<uint64_t, uint64_t> ratio;
44  };
45  using NextConfigData = boost::variant<Unused<0>, NextConfigDataV1>;
46 
47  struct ScheduledChange final : public AuthorityListChange {
49  };
50 
51  struct ForcedChange final : public AuthorityListChange {
52  ForcedChange() = default;
53 
55  uint32_t delay,
56  BlockNumber delay_start)
57  : AuthorityListChange(authorities, delay), delay_start{delay_start} {}
58 
60 
61  friend scale::ScaleDecoderStream &operator>>(scale::ScaleDecoderStream &s,
62  ForcedChange &change) {
63  return s >> change.delay_start >> change.authorities
64  >> change.subchain_length;
65  }
66 
67  friend scale::ScaleEncoderStream &operator<<(scale::ScaleEncoderStream &s,
68  const ForcedChange &change) {
69  return s << change.delay_start << change.authorities
70  << change.subchain_length;
71  }
72  };
73 
74  struct OnDisabled {
75  SCALE_TIE(1);
76  uint32_t authority_index = 0;
77  };
78 
79  struct Pause final : public DelayInChain {
81  };
82 
83  struct Resume final : public DelayInChain {
85  };
86 
87 } // namespace kagome::primitives
88 
89 #endif // KAGOME_CORE_PRIMITIVES_SCHEDULED_CHANGE
friend scale::ScaleDecoderStream & operator>>(scale::ScaleDecoderStream &s, ForcedChange &change)
Data are corresponding to the epoch.
STL namespace.
uint32_t BlockNumber
Definition: common.hpp:18
AuthorityListChange(AuthorityList authorities, uint32_t delay)
std::pair< uint64_t, uint64_t > ratio
boost::variant< Unused< 0 >, NextConfigDataV1 > NextConfigData
friend scale::ScaleEncoderStream & operator<<(scale::ScaleEncoderStream &s, const ForcedChange &change)
ForcedChange(AuthorityList authorities, uint32_t delay, BlockNumber delay_start)