pub struct ValidatorMandates { /* private fields */ }
Expand description
The mandates for a set of validators given a ValidatorMandatesConfig
.
A mandate is a liability for a validator to validate a shard. Depending on its stake and the
stake_per_mandate
specified in ValidatorMandatesConfig
, a validator may hold multiple
mandates. Each mandate may be assigned to a different shard. The assignment of mandates to
shards is calculated with Self::sample
, typically at every height.
See #9983 for context and links to resources that introduce mandates.
Implementations§
source§impl ValidatorMandates
impl ValidatorMandates
sourcepub fn new(
config: ValidatorMandatesConfig,
validators: &[ValidatorStake]
) -> Self
pub fn new( config: ValidatorMandatesConfig, validators: &[ValidatorStake] ) -> Self
Initiates mandates corresponding to the provided validators
. The validators must be sorted
by id in ascending order, so the validator with ValidatorId
equal to i
is given by
validators[i]
.
Only full mandates are assigned, partial mandates are dropped. For example, when the stake required for a mandate is 5 and a validator has staked 12, then it will obtain 2 mandates.
sourcepub fn sample<R>(&self, rng: &mut R) -> ValidatorMandatesAssignment
pub fn sample<R>(&self, rng: &mut R) -> ValidatorMandatesAssignment
Returns a validator assignment obtained by shuffling mandates and assigning them to shards.
Shard ids are shuffled as well in this process to avoid a bias lower shard ids, see
[ShuffledShardIds
].
It clones mandates since ValidatorMandates
is supposed to be valid for an epoch, while a
new assignment is calculated at every height.
Trait Implementations§
source§impl BorshDeserialize for ValidatorMandates
impl BorshDeserialize for ValidatorMandates
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
source§impl BorshSerialize for ValidatorMandates
impl BorshSerialize for ValidatorMandates
source§impl Clone for ValidatorMandates
impl Clone for ValidatorMandates
source§fn clone(&self) -> ValidatorMandates
fn clone(&self) -> ValidatorMandates
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ValidatorMandates
impl Debug for ValidatorMandates
source§impl Default for ValidatorMandates
impl Default for ValidatorMandates
source§fn default() -> ValidatorMandates
fn default() -> ValidatorMandates
source§impl PartialEq for ValidatorMandates
impl PartialEq for ValidatorMandates
source§fn eq(&self, other: &ValidatorMandates) -> bool
fn eq(&self, other: &ValidatorMandates) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for ValidatorMandates
impl Serialize for ValidatorMandates
impl Eq for ValidatorMandates
impl StructuralPartialEq for ValidatorMandates
Auto Trait Implementations§
impl Freeze for ValidatorMandates
impl RefUnwindSafe for ValidatorMandates
impl Send for ValidatorMandates
impl Sync for ValidatorMandates
impl Unpin for ValidatorMandates
impl UnwindSafe for ValidatorMandates
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
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
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more