mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 01:51:02 +00:00
impl Zero and One for fixed point numbers (#8647)
* impl Zero and One for fixed point numbers * update librocksdb-sys to support M1 * fix build * trigger CI
This commit is contained in:
Generated
+19
-23
@@ -467,26 +467,21 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bindgen"
|
name = "bindgen"
|
||||||
version = "0.54.0"
|
version = "0.57.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "66c0bb6167449588ff70803f4127f0684f9063097eca5016f37eb52b92c2cf36"
|
checksum = "fd4865004a46a0aafb2a0a5eb19d3c9fc46ee5f063a6cfc605c69ac9ecf5263d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"cfg-if 0.1.10",
|
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
"clap",
|
|
||||||
"env_logger 0.7.1",
|
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lazycell",
|
"lazycell",
|
||||||
"log",
|
|
||||||
"peeking_take_while",
|
"peeking_take_while",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"regex",
|
"regex",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"shlex",
|
"shlex",
|
||||||
"which 3.1.1",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -849,13 +844,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clang-sys"
|
name = "clang-sys"
|
||||||
version = "0.29.3"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a"
|
checksum = "853eda514c284c2287f4bf20ae614f8781f40a81d32ecda6e91449304dfe077c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glob",
|
"glob",
|
||||||
"libc",
|
"libc",
|
||||||
"libloading",
|
"libloading 0.7.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1935,7 +1930,7 @@ checksum = "03d47dad3685eceed8488986cad3d5027165ea5edb164331770e2059555f10a5"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
"libloading",
|
"libloading 0.5.2",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3092,6 +3087,16 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libloading"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"winapi 0.3.9",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libm"
|
name = "libm"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@@ -3534,9 +3539,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "librocksdb-sys"
|
name = "librocksdb-sys"
|
||||||
version = "6.11.4"
|
version = "6.17.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eb5b56f651c204634b936be2f92dbb42c36867e00ff7fe2405591f3b9fa66f09"
|
checksum = "5da125e1c0f22c7cae785982115523a0738728498547f415c9054cb17c7e89f9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"cc",
|
"cc",
|
||||||
@@ -6236,7 +6241,7 @@ dependencies = [
|
|||||||
"prost",
|
"prost",
|
||||||
"prost-types",
|
"prost-types",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"which 4.0.2",
|
"which",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -11053,15 +11058,6 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "which"
|
|
||||||
version = "3.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "which"
|
name = "which"
|
||||||
version = "4.0.2"
|
version = "4.0.2"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use frame_support::{
|
|||||||
weights::{GetDispatchInfo, constants::ExtrinsicBaseWeight, IdentityFee, WeightToFeePolynomial},
|
weights::{GetDispatchInfo, constants::ExtrinsicBaseWeight, IdentityFee, WeightToFeePolynomial},
|
||||||
};
|
};
|
||||||
use sp_core::NeverNativeValue;
|
use sp_core::NeverNativeValue;
|
||||||
use sp_runtime::{Perbill, FixedPointNumber};
|
use sp_runtime::{Perbill, traits::One};
|
||||||
use node_runtime::{
|
use node_runtime::{
|
||||||
CheckedExtrinsic, Call, Runtime, Balances, TransactionPayment, Multiplier,
|
CheckedExtrinsic, Call, Runtime, Balances, TransactionPayment, Multiplier,
|
||||||
TransactionByteFee,
|
TransactionByteFee,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl OnUnbalanced<NegativeImbalance> for Author {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod multiplier_tests {
|
mod multiplier_tests {
|
||||||
use sp_runtime::{assert_eq_error_rate, FixedPointNumber, traits::Convert};
|
use sp_runtime::{assert_eq_error_rate, FixedPointNumber, traits::{Convert, One, Zero}};
|
||||||
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
|
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ mod tests {
|
|||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
testing::{Header, TestXt},
|
testing::{Header, TestXt},
|
||||||
traits::{BlakeTwo256, IdentityLookup},
|
traits::{BlakeTwo256, IdentityLookup, One},
|
||||||
transaction_validity::InvalidTransaction,
|
transaction_validity::InvalidTransaction,
|
||||||
Perbill,
|
Perbill,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ pub trait FixedPointNumber:
|
|||||||
+ Saturating + Bounded
|
+ Saturating + Bounded
|
||||||
+ Eq + PartialEq + Ord + PartialOrd
|
+ Eq + PartialEq + Ord + PartialOrd
|
||||||
+ CheckedSub + CheckedAdd + CheckedMul + CheckedDiv
|
+ CheckedSub + CheckedAdd + CheckedMul + CheckedDiv
|
||||||
+ Add + Sub + Div + Mul
|
+ Add + Sub + Div + Mul + Zero + One
|
||||||
{
|
{
|
||||||
/// The underlying data type used for this fixed point number.
|
/// The underlying data type used for this fixed point number.
|
||||||
type Inner: Debug + One + CheckedMul + CheckedDiv + FixedPointOperand;
|
type Inner: Debug + One + CheckedMul + CheckedDiv + FixedPointOperand;
|
||||||
@@ -195,21 +195,6 @@ pub trait FixedPointNumber:
|
|||||||
Self::one().checked_div(&self)
|
Self::one().checked_div(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns zero.
|
|
||||||
fn zero() -> Self {
|
|
||||||
Self::from_inner(Self::Inner::zero())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Checks if the number is zero.
|
|
||||||
fn is_zero(&self) -> bool {
|
|
||||||
self.into_inner() == Self::Inner::zero()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns one.
|
|
||||||
fn one() -> Self {
|
|
||||||
Self::from_inner(Self::DIV)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Checks if the number is one.
|
/// Checks if the number is one.
|
||||||
fn is_one(&self) -> bool {
|
fn is_one(&self) -> bool {
|
||||||
self.into_inner() == Self::Inner::one()
|
self.into_inner() == Self::Inner::one()
|
||||||
@@ -514,6 +499,22 @@ macro_rules! implement_fixed {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Zero for $name {
|
||||||
|
fn zero() -> Self {
|
||||||
|
Self::from_inner(<Self as FixedPointNumber>::Inner::zero())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_zero(&self) -> bool {
|
||||||
|
self.into_inner() == <Self as FixedPointNumber>::Inner::zero()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl One for $name {
|
||||||
|
fn one() -> Self {
|
||||||
|
Self::from_inner(Self::DIV)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl sp_std::fmt::Debug for $name {
|
impl sp_std::fmt::Debug for $name {
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
|
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
|
||||||
|
|||||||
Reference in New Issue
Block a user