Linear weighting struct
Get the simple things down first.
#
GoalUnderstand how to calculate transaction weights using a custom weighting struct for single transaction values.
#
Use casesCalculate correct weight for a transaction involving a u32
.
#
OverviewThis guide goes over the components of a simple weighting struct designed for a single argument dispatch of type u32
.
The ultimate weight of the transaction is the product of the transaction parameter and the field of this struct.
#
StepsWeighData
struct#
1. Write the Using WeighData
, write a weighting struct that takes a single u32
parameter:
#
2. Classify dispatch callsSince this implementation of WeighData
requires a Dispatch
, use [default
][dispatchclass-rustdocs] to classify all calls as normal—as opposed to operational.
PaysFee
#
3. Implement Implement the PaysFee
trait to indicate whether fees should actually be charged from the caller. If not, the weights are still applied toward the block maximums.
#
Examples- Feeless transaction pallet
- pallet-weights