From 8e49a5647584cdb8dd6890ed30cb1b551c32d1bc Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 11 Oct 2022 22:46:58 +0800 Subject: [PATCH 1/3] Rename `from_components` to `from_parts` --- primitives/weights/src/weight_v2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/weights/src/weight_v2.rs b/primitives/weights/src/weight_v2.rs index 8596a782c1fa7..217d5570d7100 100644 --- a/primitives/weights/src/weight_v2.rs +++ b/primitives/weights/src/weight_v2.rs @@ -113,7 +113,7 @@ impl Weight { } /// Construct [`Weight`] with weight components, namely reference time and storage size weights. - pub const fn from_components(ref_time: u64, proof_size: u64) -> Self { + pub const fn from_parts(ref_time: u64, proof_size: u64) -> Self { Self { ref_time, proof_size } } From 88d808307f75daf01b1eca50ab1a433116f76edb Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 11 Oct 2022 23:22:08 +0800 Subject: [PATCH 2/3] Fixes --- frame/contracts/src/gas.rs | 2 +- frame/election-provider-multi-phase/src/mock.rs | 2 +- frame/system/src/limits.rs | 2 +- primitives/weights/src/weight_v2.rs | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index d0076652dd6d4..c0cc2db2aa3eb 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -109,7 +109,7 @@ where pub fn nested(&mut self, amount: Weight) -> Result { // NOTE that it is ok to allocate all available gas since it still ensured // by `charge` that it doesn't reach zero. - let amount = Weight::from_components( + let amount = Weight::from_parts( if amount.ref_time().is_zero() { self.gas_left().ref_time() } else { diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 2615d863c91e0..6a638c8d2a2e1 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -239,7 +239,7 @@ parameter_types! { pub const ExistentialDeposit: u64 = 1; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights ::with_sensible_defaults( - Weight::from_components(2u64 * constants::WEIGHT_PER_SECOND.ref_time(), u64::MAX), + Weight::from_parts(2u64 * constants::WEIGHT_PER_SECOND.ref_time(), u64::MAX), NORMAL_DISPATCH_RATIO, ); } diff --git a/frame/system/src/limits.rs b/frame/system/src/limits.rs index 07ad240afe159..eb95b699eba32 100644 --- a/frame/system/src/limits.rs +++ b/frame/system/src/limits.rs @@ -208,7 +208,7 @@ pub struct BlockWeights { impl Default for BlockWeights { fn default() -> Self { Self::with_sensible_defaults( - Weight::from_components(constants::WEIGHT_PER_SECOND.ref_time(), u64::MAX), + Weight::from_parts(constants::WEIGHT_PER_SECOND.ref_time(), u64::MAX), DEFAULT_NORMAL_RATIO, ) } diff --git a/primitives/weights/src/weight_v2.rs b/primitives/weights/src/weight_v2.rs index 217d5570d7100..a1867c7bae462 100644 --- a/primitives/weights/src/weight_v2.rs +++ b/primitives/weights/src/weight_v2.rs @@ -112,7 +112,7 @@ impl Weight { Self { ref_time: 0, proof_size } } - /// Construct [`Weight`] with weight components, namely reference time and storage size weights. + /// Construct [`Weight`] from weight parts, namely reference time and storage size weights. pub const fn from_parts(ref_time: u64, proof_size: u64) -> Self { Self { ref_time, proof_size } } @@ -455,8 +455,8 @@ mod tests { #[test] fn is_zero_works() { assert!(Weight::zero().is_zero()); - assert!(!Weight::from_components(1, 0).is_zero()); - assert!(!Weight::from_components(0, 1).is_zero()); + assert!(!Weight::from_parts(1, 0).is_zero()); + assert!(!Weight::from_parts(0, 1).is_zero()); assert!(!Weight::MAX.is_zero()); } } From e43aa1359bb757c74dcbe0b864d93e98bd609517 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 11 Oct 2022 23:26:00 +0800 Subject: [PATCH 3/3] Spelling --- primitives/weights/src/weight_v2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/weights/src/weight_v2.rs b/primitives/weights/src/weight_v2.rs index a1867c7bae462..2933d80099dd7 100644 --- a/primitives/weights/src/weight_v2.rs +++ b/primitives/weights/src/weight_v2.rs @@ -112,7 +112,7 @@ impl Weight { Self { ref_time: 0, proof_size } } - /// Construct [`Weight`] from weight parts, namely reference time and storage size weights. + /// Construct [`Weight`] from weight parts, namely reference time and proof size weights. pub const fn from_parts(ref_time: u64, proof_size: u64) -> Self { Self { ref_time, proof_size } }