-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Phragmén Validator Election #1915
Changes from 1 commit
89417a1
cf8157c
b0b8e21
653456f
ee38f86
f969335
2c02b54
89185ec
baf8778
cfaf7b9
9408b95
b2973a3
e9b5244
cabdc5b
9584ac7
747d650
216be37
9365327
d3ad7b4
938bd7b
ed487ec
043d182
d605e26
633bb37
cac9d3f
f8b04a3
3bd69ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,11 +250,14 @@ impl From<codec::Compact<Perbill>> for Perbill { | |
|
|
||
| /// Perquill is parts-per-quintillion. It stores a value between 0 and 1 in fixed point and | ||
| /// provides a means to multiply some other value by that. | ||
| #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] | ||
| #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] | ||
| #[derive(Encode, Decode, Default, Copy, Clone, PartialEq, Eq)] | ||
| pub struct Perquill(u64); | ||
|
|
||
| impl Perquill { | ||
| /// Returns the internal u64 value | ||
| pub fn extract(&self) -> u64 { self.0 } | ||
|
|
||
| /// Nothing. | ||
| pub fn zero() -> Perquill { Perquill(0) } | ||
|
||
|
|
||
|
|
@@ -270,17 +273,14 @@ impl Perquill { | |
| /// Construct new instance where `x` is in millionths. Value equivalent to `x / 1,000,000`. | ||
| pub fn from_millionths(x: u64) -> Perquill { Perquill(x.min(1_000_000) * 1000_000_000_000) } | ||
|
|
||
| /// Construct new instance where `x` is denominator and the nominator is 1. | ||
| pub fn from_xth(x: u64) -> Perquill { Perquill(1_000_000_000_000_000_000 / x.min(1_000_000_000_000_000_000)) } | ||
|
|
||
| #[cfg(feature = "std")] | ||
| /// Construct new instance whose value is equal to `x` (between 0 and 1). | ||
| pub fn from_fraction(x: f64) -> Perquill { Perquill((x.max(0.0).min(1.0) * 1_000_000_000_000_000_000.0) as u64) } | ||
|
||
| } | ||
|
|
||
| impl std::fmt::Debug for Perquill { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
| write!(f, "Perquill(~{}) ", self.0 as f64/1_000_000_000_000_000_000.0) | ||
| } | ||
| } | ||
|
|
||
| impl<N> ::rstd::ops::Mul<N> for Perquill | ||
| where | ||
| N: traits::As<u64> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this function and implement
Derefto get the same functionality.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deref is meant to be for smart pointers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well... Its currently changed to
Derefinstead ofextract().Docs says:
From which I understand it is good for smart pointers, not exclusive.
Though I am personally in favor of
.extract()or anything else since I hate this type of code.747d650#diff-ba0a45203e7c14aedb758fe4d3653b35R138