Kagome
Polkadot Runtime Engine in C++17
runtime_dispatch_info.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_RUNTIME_DISPATCH_INFO_HPP
7 #define KAGOME_RUNTIME_DISPATCH_INFO_HPP
8 
9 namespace kagome::primitives {
10 
15  using Weight = uint64_t;
16  using Balance = uint32_t;
17 
19 
20  enum class DispatchClass {
21  Normal,
23  /* A mandatory dispatch. These kinds of dispatch are always included
24  * regardless of their weight, therefore it is critical that they are
25  * separately validated to ensure that a malicious validator cannot craft
26  * a valid but impossibly heavy block. Usually this just means ensuring
27  * that the extrinsic can only be included once and that it is always very
28  * light.
29  *
30  * Do *NOT* use it for extrinsics that can be heavy.
31  *
32  * The only real use case for this is inherent extrinsics that are
33  * required to execute in a block for the block to be valid, and it solves
34  * the issue in the case that the block initialization is sufficiently
35  * heavy to mean that those inherents do not fit into the block.
36  * Essentially, we assume that in these exceptional circumstances, it is
37  * better to allow an overweight block to be created than to not allow any
38  * block at all to be created.
39  */
40  Mandatory
42 
48  };
49 
50  template <class Stream,
51  typename = std::enable_if_t<Stream::is_encoder_stream>>
53  return s << v.weight << v.dispatch_class << v.partial_fee;
54  }
55 
56  template <class Stream,
57  typename = std::enable_if_t<Stream::is_decoder_stream>>
59  uint8_t dispatch_class;
60  s >> v.weight >> dispatch_class >> v.partial_fee;
61  v.dispatch_class =
63  return s;
64  }
65 
66 } // namespace kagome::primitives
67 
68 #endif // KAGOME_RUNTIME_DISPATCH_INFO_HPP
Stream & operator>>(Stream &s, ArithmeticError &v)
enum kagome::primitives::RuntimeDispatchInfo::DispatchClass dispatch_class
Stream & operator<<(Stream &s, const ArithmeticError &v)
libp2p::connection::Stream Stream