git.delta.rocks / unique-network / refs/commits / e725f8510927

difftreelog

Replace spaces with tabs

Greg Zaitsev2021-04-07parent: #9d35eac.patch.diff
in: master

2 files changed

modifiedpallets/inflation/src/lib.rsdiffbeforeafterboth
--- a/pallets/inflation/src/lib.rs
+++ b/pallets/inflation/src/lib.rs
@@ -20,19 +20,19 @@
 mod tests;
 
 pub use frame_support::{
-    construct_runtime, decl_module, decl_storage,
-    ensure,
-    traits::{
-        Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,
-        Randomness, IsSubType, WithdrawReasons,
-    },
-    weights::{
-        constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
-        DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
-        WeightToFeePolynomial, DispatchClass,
-    },
-    StorageValue,
-    transactional,
+	construct_runtime, decl_module, decl_storage,
+	ensure,
+	traits::{
+		Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,
+		Randomness, IsSubType, WithdrawReasons,
+	},
+	weights::{
+		constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
+		DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
+		WeightToFeePolynomial, DispatchClass,
+	},
+	StorageValue,
+	transactional,
 };
 
 // #[cfg(feature = "runtime-benchmarks")]
@@ -40,7 +40,7 @@
 
 use sp_runtime::{
 	Perbill,
-    traits::{Zero}
+	traits::{Zero}
 };
 use sp_std::convert::TryInto;
 
@@ -56,75 +56,75 @@
 pub const END_INFLATION_PERCENT: u32 = 4;
 
 pub trait Config: system::Config {
-    type Currency: Currency<Self::AccountId>;
-    type TreasuryAccountId: Get<Self::AccountId>;
-    type InflationBlockInterval: Get<Self::BlockNumber>;
+	type Currency: Currency<Self::AccountId>;
+	type TreasuryAccountId: Get<Self::AccountId>;
+	type InflationBlockInterval: Get<Self::BlockNumber>;
 }
 
 decl_storage! {
-    trait Store for Module<T: Config> as Inflation {
-        /// starting year total issuance
-        pub StartingYearTotalIssuance get(fn starting_year_total_issuance): BalanceOf<T>;
+	trait Store for Module<T: Config> as Inflation {
+		/// starting year total issuance
+		pub StartingYearTotalIssuance get(fn starting_year_total_issuance): BalanceOf<T>;
 
-        /// Current block inflation
-        pub BlockInflation get(fn block_inflation): BalanceOf<T>;
-    }
+		/// Current block inflation
+		pub BlockInflation get(fn block_inflation): BalanceOf<T>;
+	}
 }
 
 decl_module! {
-    pub struct Module<T: Config> for enum Call 
-    where 
-        origin: T::Origin,
-    {
-        const InflationBlockInterval: T::BlockNumber = T::InflationBlockInterval::get();
+	pub struct Module<T: Config> for enum Call 
+	where 
+		origin: T::Origin,
+	{
+		const InflationBlockInterval: T::BlockNumber = T::InflationBlockInterval::get();
 
-        fn on_initialize(now: T::BlockNumber) -> Weight 
-        {
+		fn on_initialize(now: T::BlockNumber) -> Weight 
+		{
 			let mut consumed_weight = 0;
 			let mut add_weight = |reads, writes, weight| {
 				consumed_weight += T::DbWeight::get().reads_writes(reads, writes);
 				consumed_weight += weight;
 			};
 
-            let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);
+			let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);
 
-            // Recalculate inflation on the first block of the year (or if it is not initialized yet)
-            if (now % T::BlockNumber::from(YEAR)).is_zero() || <BlockInflation<T>>::get().is_zero() {
-                let current_year: u32 = (now / T::BlockNumber::from(YEAR)).try_into().unwrap_or(0);
+			// Recalculate inflation on the first block of the year (or if it is not initialized yet)
+			if (now % T::BlockNumber::from(YEAR)).is_zero() || <BlockInflation<T>>::get().is_zero() {
+				let current_year: u32 = (now / T::BlockNumber::from(YEAR)).try_into().unwrap_or(0);
 
-                let one_percent = Perbill::from_percent(1);
+				let one_percent = Perbill::from_percent(1);
 
-                if current_year <= TOTAL_YEARS_UNTIL_FLAT {
-                    let amount: BalanceOf<T> = Perbill::from_rational_approximation(
-                        block_interval * (START_INFLATION_PERCENT * TOTAL_YEARS_UNTIL_FLAT - current_year * (START_INFLATION_PERCENT - END_INFLATION_PERCENT)), 
-                        YEAR * TOTAL_YEARS_UNTIL_FLAT
-                    ) * ( one_percent * T::Currency::total_issuance() );
-                    <BlockInflation<T>>::put(amount);
-                }
-                else {
-                    let amount: BalanceOf<T> = Perbill::from_rational_approximation(
-                        block_interval * END_INFLATION_PERCENT, 
-                        YEAR
-                    ) * (one_percent * T::Currency::total_issuance());
-                    <BlockInflation<T>>::put(amount);
-                }
-                <StartingYearTotalIssuance<T>>::set(T::Currency::total_issuance());
+				if current_year <= TOTAL_YEARS_UNTIL_FLAT {
+					let amount: BalanceOf<T> = Perbill::from_rational_approximation(
+						block_interval * (START_INFLATION_PERCENT * TOTAL_YEARS_UNTIL_FLAT - current_year * (START_INFLATION_PERCENT - END_INFLATION_PERCENT)), 
+						YEAR * TOTAL_YEARS_UNTIL_FLAT
+					) * ( one_percent * T::Currency::total_issuance() );
+					<BlockInflation<T>>::put(amount);
+				}
+				else {
+					let amount: BalanceOf<T> = Perbill::from_rational_approximation(
+						block_interval * END_INFLATION_PERCENT, 
+						YEAR
+					) * (one_percent * T::Currency::total_issuance());
+					<BlockInflation<T>>::put(amount);
+				}
+				<StartingYearTotalIssuance<T>>::set(T::Currency::total_issuance());
 
-                // First time deposit
-                T::Currency::deposit_creating(&T::TreasuryAccountId::get(), <BlockInflation<T>>::get());
+				// First time deposit
+				T::Currency::deposit_creating(&T::TreasuryAccountId::get(), <BlockInflation<T>>::get());
 
-                add_weight(7, 6, 28_300_000);
-            }
+				add_weight(7, 6, 28_300_000);
+			}
 
-            // Apply inflation every InflationBlockInterval blocks and in the 1st block to initialize Treasury account
-            else if (now % T::BlockNumber::from(block_interval)).is_zero() {
-                T::Currency::deposit_into_existing(&T::TreasuryAccountId::get(), <BlockInflation<T>>::get()).ok();
+			// Apply inflation every InflationBlockInterval blocks and in the 1st block to initialize Treasury account
+			else if (now % T::BlockNumber::from(block_interval)).is_zero() {
+				T::Currency::deposit_into_existing(&T::TreasuryAccountId::get(), <BlockInflation<T>>::get()).ok();
 
-                add_weight(3, 2, 12_900_000);
-            }
+				add_weight(3, 2, 12_900_000);
+			}
 
-            consumed_weight
-        }
+			consumed_weight
+		}
 
-    }
+	}
 }
modifiedpallets/inflation/src/tests.rsdiffbeforeafterboth

no syntactic changes