Struct chain_impl_mockchain::stake::PercentStake
source · pub struct PercentStake {
pub stake: Stake,
pub total: Stake,
}
Fields§
§stake: Stake
§total: Stake
Implementations§
source§impl PercentStake
impl PercentStake
pub fn new(stake: Stake, total: Stake) -> Self
pub fn as_float(&self) -> f64
sourcepub fn scale_value(&self, v: Value) -> Value
pub fn scale_value(&self, v: Value) -> Value
Apply this ratio to a value
Returned Value = (Value / Total) * Stake
note that we augment the precision by 10^18 to prevent early zeroing, as we do the operation using fixed sized integers
Trait Implementations§
source§impl Clone for PercentStake
impl Clone for PercentStake
source§fn clone(&self) -> PercentStake
fn clone(&self) -> PercentStake
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PercentStake
impl Debug for PercentStake
source§impl PartialEq<PercentStake> for PercentStake
impl PartialEq<PercentStake> for PercentStake
source§fn eq(&self, other: &PercentStake) -> bool
fn eq(&self, other: &PercentStake) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for PercentStake
impl StructuralEq for PercentStake
impl StructuralPartialEq for PercentStake
Auto Trait Implementations§
impl RefUnwindSafe for PercentStake
impl Send for PercentStake
impl Sync for PercentStake
impl Unpin for PercentStake
impl UnwindSafe for PercentStake
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more