difftreelog
Format inflation
in: master
1 file changed
pallets/inflation/src/lib.rsdiffbeforeafterboth19pub use pallet::*;19pub use pallet::*;20use sp_runtime::{20use sp_runtime::{21 Perbill,21 Perbill,22 traits::{BlockNumberProvider}22 traits::{BlockNumberProvider},23};23};242425use 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) -> Weight78 where <T as frame_system::Config>::BlockNumber: From<u32>81 where82 <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) {9495 // 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 Treasury121 /// 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 /// # Permissions140 inflation_start_relay_block: T::BlockNumber,141 ) -> DispatchResult132 where <T as frame_system::Config>::BlockNumber: From<u32> {142 where143 <T as frame_system::Config>::BlockNumber: From<u32>,144 {133 ensure_root(origin)?;145 ensure_root(origin)?;134146