git.delta.rocks / unique-network / refs/commits / 4a7e62453178

difftreelog

Format inflation

Greg Zaitsev2021-12-07parent: #4e00e0c.patch.diff
in: master

1 file changed

modifiedpallets/inflation/src/lib.rsdiffbeforeafterboth
19pub use pallet::*;19pub use pallet::*;
20use sp_runtime::{20use sp_runtime::{
21 Perbill,21 Perbill,
22 traits::{BlockNumberProvider}22 traits::{BlockNumberProvider},
23};23};
2424
25use sp_std::convert::TryInto;25use sp_std::convert::TryInto;
76 impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {79 impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
77 fn on_initialize(_: T::BlockNumber) -> Weight80 fn on_initialize(_: T::BlockNumber) -> Weight
78 where <T as frame_system::Config>::BlockNumber: From<u32>81 where
82 <T as frame_system::Config>::BlockNumber: From<u32>,
79 {83 {
80 let mut consumed_weight = 0;84 let mut consumed_weight = 0;
81 let mut add_weight = |reads, writes, weight| {85 let mut add_weight = |reads, writes, weight| {
93 if (next_inflation != 0u32.into()) && (current_relay_block >= next_inflation) {97 if (next_inflation != 0u32.into()) && (current_relay_block >= next_inflation) {
94
95 // Recalculate inflation on the first block of the year (or if it is not initialized yet)98 // Recalculate inflation on the first block of the year (or if it is not initialized yet)
96 // Do the "current_relay_block >= next_recalculation" check in the "current_relay_block >= next_inflation" 99 // Do the "current_relay_block >= next_recalculation" check in the "current_relay_block >= next_inflation"
97 // block because it saves InflationBlockInterval DB reads for NextRecalculationBlock.100 // block because it saves InflationBlockInterval DB reads for NextRecalculationBlock.
98 let next_recalculation: T::BlockNumber = <NextRecalculationBlock<T>>::get();101 let next_recalculation: T::BlockNumber = <NextRecalculationBlock<T>>::get();
99 add_weight(1, 0, 0);102 add_weight(1, 0, 0);
117 #[pallet::call]124 #[pallet::call]
118 impl<T: Config> Pallet<T> {125 impl<T: Config> Pallet<T> {
119 /// This method sets the inflation start date. Can be only called once.126 /// This method sets the inflation start date. Can be only called once.
120 /// Inflation start block can be backdated and will catch up. The method will create Treasury 127 /// Inflation start block can be backdated and will catch up. The method will create Treasury
121 /// account if it does not exist and perform the first inflation deposit.128 /// account if it does not exist and perform the first inflation deposit.
122 ///129 ///
123 /// # Permissions130 /// # Permissions
140 inflation_start_relay_block: T::BlockNumber,
141 ) -> DispatchResult
132 where <T as frame_system::Config>::BlockNumber: From<u32> {142 where
143 <T as frame_system::Config>::BlockNumber: From<u32>,
144 {
133 ensure_root(origin)?;145 ensure_root(origin)?;
134146