Crate generate_bags
source ·Expand description
Support code to ease the process of generating bag thresholds.
NOTE: this assume the runtime implements [pallet_staking::Config
], as it requires an
implementation of the traits [frame_support::traits::Currency
] and CurrencyToVote
.
The process of adding bags to a runtime requires only four steps.
-
Update the runtime definition.
ⓘparameter_types!{ pub const BagThresholds: &'static [u64] = &[]; } impl pallet_bags_list::Config for Runtime { // <snip> type BagThresholds = BagThresholds; }
-
Write a little program to generate the definitions. This program exists only to hook together the runtime definitions with the various calculations here. Take a look at utils/frame/generate_bags/node-runtime for an example.
-
Run that program:
$ cargo run -p node-runtime-generate-bags -- --total-issuance 1234 --minimum-balance 1
output.rs ```
-
Update the runtime definition.
+ mod output; - pub const BagThresholds: &'static [u64] = &[]; + pub const BagThresholds: &'static [u64] = &output::THRESHOLDS;
Functions§
- Compute the constant ratio for the thresholds.
- Write a thresholds module to the path specified.
- Compute the list of bag thresholds.