[][src]Module frame_support::weights

Primitives for transaction weighting.

All dispatchable functions defined in decl_module! must provide two trait implementations:

  • [WeightData]: To determine the weight of the dispatch.
  • ClassifyDispatch: To determine the class of the dispatch. See the enum definition for more information on dispatch classes.

Every dispatchable function is responsible for providing this data via an optional #[weight = $x] attribute. In this snipped, $x can be any user provided struct that implements the two aforementioned traits.

Substrate then bundles then output information of the two traits into DispatchInfo struct and provides it by implementing the GetDispatchInfo for all Call variants, and opaque extrinsic types.

If no #[weight] is defined, the macro automatically injects the Default implementation of the SimpleDispatchInfo.

Note that the decl_module macro cannot enforce this and will simply fail if an invalid struct (something that does not implement Weighable) is passed in.

Structs

DispatchInfo

A bundle of static information collected from the #[weight = $x] attributes.

FunctionOf

A struct to represent a weight which is a function of the input arguments. The given items have the following types:

Enums

DispatchClass

A generalized group of dispatch types. This is only distinguishing normal, user-triggered transactions (Normal) and anything beyond which serves a higher purpose to the system (Operational).

SimpleDispatchInfo

Default type used with the #[weight = x] attribute in a substrate chain.

Traits

ClassifyDispatch

Means of classifying a dispatchable function.

GetDispatchInfo

A Dispatchable function (aka transaction) that can carry some static information along with it, using the #[weight] attribute.

PaysFee

Indicates if dispatch function should pay fees or not. If set to false, the block resource limits are applied, yet no fee is deducted.

WeighBlock

Means of determining the weight of a block's life cycle hooks: on_initialize, on_finalize and such.

WeighData

Means of weighing some particular kind of data (T).

Type Definitions

TransactionPriority

Re-export priority as type Priority for a transaction. Additive. Higher is better.

Weight

Numeric range of a transaction weight.