pub struct ValidatorMap<T>(/* private fields */);
Expand description
A map from the set of validators to some values.
Implementations§
Source§impl<C: Context> ValidatorMap<Observation<C>>
impl<C: Context> ValidatorMap<Observation<C>>
Sourcepub fn has_correct(&self) -> bool
pub fn has_correct(&self) -> bool
Returns true
if there is at least one correct observation.
Sourcepub fn iter_correct<'a>(
&'a self,
state: &'a State<C>,
) -> impl Iterator<Item = &'a Unit<C>>
pub fn iter_correct<'a>( &'a self, state: &'a State<C>, ) -> impl Iterator<Item = &'a Unit<C>>
Returns an iterator over all honest validators’ latest units.
Sourcepub fn iter_correct_hashes(&self) -> impl Iterator<Item = &C::Hash>
pub fn iter_correct_hashes(&self) -> impl Iterator<Item = &C::Hash>
Returns an iterator over all honest validators’ latest units’ hashes.
Sourcepub fn iter_faulty(&self) -> impl Iterator<Item = ValidatorIndex> + '_
pub fn iter_faulty(&self) -> impl Iterator<Item = ValidatorIndex> + '_
Returns an iterator over all faulty validators’ indices.
Sourcepub fn iter_none(&self) -> impl Iterator<Item = ValidatorIndex> + '_
pub fn iter_none(&self) -> impl Iterator<Item = ValidatorIndex> + '_
Returns an iterator over all faulty validators’ indices.
Sourcepub fn sees_correct(&self, state: &State<C>, hash: &C::Hash) -> bool
pub fn sees_correct(&self, state: &State<C>, hash: &C::Hash) -> bool
Returns true
if self
sees the creator of hash
as correct, and sees that unit.
Sourcepub fn sees(&self, state: &State<C>, hash_to_be_found: &C::Hash) -> bool
pub fn sees(&self, state: &State<C>, hash_to_be_found: &C::Hash) -> bool
Returns true
if self
sees the unit with the specified hash
.
Source§impl<T> ValidatorMap<T>
impl<T> ValidatorMap<T>
Sourcepub fn get(&self, idx: ValidatorIndex) -> Option<&T>
pub fn get(&self, idx: ValidatorIndex) -> Option<&T>
Returns the value for the given validator, or None
if the index is out of range.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of values. This must equal the number of validators.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
Returns an iterator over mutable references to all values.
Sourcepub fn enumerate(&self) -> impl Iterator<Item = (ValidatorIndex, &T)>
pub fn enumerate(&self) -> impl Iterator<Item = (ValidatorIndex, &T)>
Returns an iterator over all values, by validator index.
Sourcepub fn has(&self, idx: ValidatorIndex) -> bool
pub fn has(&self, idx: ValidatorIndex) -> bool
Returns true
if self
has an entry for validator number idx
.
Sourcepub fn keys(&self) -> impl Iterator<Item = ValidatorIndex>
pub fn keys(&self) -> impl Iterator<Item = ValidatorIndex>
Returns an iterator over all validator indices.
Sourcepub fn binary_search(&self, x: &T) -> Option<ValidatorIndex>where
T: Ord,
pub fn binary_search(&self, x: &T) -> Option<ValidatorIndex>where
T: Ord,
Binary searches this sorted ValidatorMap
for x
.
Returns the lowest index of an entry >= x
, or None
if x
is greater than all entries.
Source§impl<T> ValidatorMap<Option<T>>
impl<T> ValidatorMap<Option<T>>
Sourcepub fn keys_some(&self) -> impl Iterator<Item = ValidatorIndex> + '_
pub fn keys_some(&self) -> impl Iterator<Item = ValidatorIndex> + '_
Returns the keys of all validators whose value is Some
.
Sourcepub fn iter_some(&self) -> impl Iterator<Item = (ValidatorIndex, &T)> + '_
pub fn iter_some(&self) -> impl Iterator<Item = (ValidatorIndex, &T)> + '_
Returns an iterator over all values that are present, together with their index.
Trait Implementations§
Source§impl<Rhs, T: Copy + Add<Rhs, Output = T>> Add<ValidatorMap<Rhs>> for ValidatorMap<T>
impl<Rhs, T: Copy + Add<Rhs, Output = T>> Add<ValidatorMap<Rhs>> for ValidatorMap<T>
Source§type Output = ValidatorMap<T>
type Output = ValidatorMap<T>
+
operator.Source§impl<T> AsRef<Vec<T>> for ValidatorMap<T>
impl<T> AsRef<Vec<T>> for ValidatorMap<T>
Source§impl<T: Clone> Clone for ValidatorMap<T>
impl<T: Clone> Clone for ValidatorMap<T>
Source§fn clone(&self) -> ValidatorMap<T>
fn clone(&self) -> ValidatorMap<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T> DataSize for ValidatorMap<T>where
T: DataSize,
impl<T> DataSize for ValidatorMap<T>where
T: DataSize,
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
true
, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
IS_DYNAMIC
is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Source§fn estimate_detailed_heap_size(&self) -> MemUsageNode
fn estimate_detailed_heap_size(&self) -> MemUsageNode
Source§impl<T: Debug> Debug for ValidatorMap<T>
impl<T: Debug> Debug for ValidatorMap<T>
Source§impl<'de, T> Deserialize<'de> for ValidatorMap<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ValidatorMap<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T> From<Vec<T>> for ValidatorMap<T>
impl<T> From<Vec<T>> for ValidatorMap<T>
Source§fn from(original: Vec<T>) -> ValidatorMap<T>
fn from(original: Vec<T>) -> ValidatorMap<T>
Source§impl<T> FromIterator<T> for ValidatorMap<T>
impl<T> FromIterator<T> for ValidatorMap<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(ii: I) -> ValidatorMap<T>
fn from_iter<I: IntoIterator<Item = T>>(ii: I) -> ValidatorMap<T>
Source§impl<T: Hash> Hash for ValidatorMap<T>
impl<T: Hash> Hash for ValidatorMap<T>
Source§impl<T> Index<ValidatorIndex> for ValidatorMap<T>
impl<T> Index<ValidatorIndex> for ValidatorMap<T>
Source§impl<T> IndexMut<ValidatorIndex> for ValidatorMap<T>
impl<T> IndexMut<ValidatorIndex> for ValidatorMap<T>
Source§impl<'a, T> IntoIterator for &'a ValidatorMap<T>
impl<'a, T> IntoIterator for &'a ValidatorMap<T>
Source§impl<T> IntoIterator for ValidatorMap<T>
impl<T> IntoIterator for ValidatorMap<T>
Source§impl<T: PartialEq> PartialEq for ValidatorMap<T>
impl<T: PartialEq> PartialEq for ValidatorMap<T>
Source§impl<T> Serialize for ValidatorMap<T>where
T: Serialize,
impl<T> Serialize for ValidatorMap<T>where
T: Serialize,
impl<T: Eq> Eq for ValidatorMap<T>
impl<T> StructuralPartialEq for ValidatorMap<T>
Auto Trait Implementations§
impl<T> Freeze for ValidatorMap<T>
impl<T> RefUnwindSafe for ValidatorMap<T>where
T: RefUnwindSafe,
impl<T> Send for ValidatorMap<T>where
T: Send,
impl<T> Sync for ValidatorMap<T>where
T: Sync,
impl<T> Unpin for ValidatorMap<T>where
T: Unpin,
impl<T> UnwindSafe for ValidatorMap<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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<From, To> FallibleInto<To> for Fromwhere
To: TryFrom<From>,
impl<From, To> FallibleInto<To> for Fromwhere
To: TryFrom<From>,
fn try_into_wrapped(self) -> Result<To, VMError>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.