pub struct Committee {
pub validators: BTreeMap<ValidatorPublicKey, ValidatorState>,
/* private fields */
}Expand description
A set of validators (identified by their public keys) and their voting rights.
Fields§
§validators: BTreeMap<ValidatorPublicKey, ValidatorState>The validators in the committee.
Implementations§
Source§impl Committee
impl Committee
Sourcepub fn new(
validators: BTreeMap<ValidatorPublicKey, ValidatorState>,
policy: ResourceControlPolicy,
) -> Self
pub fn new( validators: BTreeMap<ValidatorPublicKey, ValidatorState>, policy: ResourceControlPolicy, ) -> Self
Creates a new committee from the given validators and resource control policy.
Sourcepub fn weight(&self, author: &ValidatorPublicKey) -> u64
pub fn weight(&self, author: &ValidatorPublicKey) -> u64
Returns the number of votes held by the given validator, or zero if it is not a member.
Sourcepub fn account_keys_and_weights(
&self,
) -> impl Iterator<Item = (AccountPublicKey, u64)> + '_
pub fn account_keys_and_weights( &self, ) -> impl Iterator<Item = (AccountPublicKey, u64)> + '_
Returns an iterator over each validator’s account public key and its number of votes.
Sourcepub fn quorum_threshold(&self) -> u64
pub fn quorum_threshold(&self) -> u64
Returns the number of votes required to reach a quorum.
Sourcepub fn validity_threshold(&self) -> u64
pub fn validity_threshold(&self) -> u64
Returns the number of votes required to reach the validity threshold.
Sourcepub fn validators(&self) -> &BTreeMap<ValidatorPublicKey, ValidatorState>
pub fn validators(&self) -> &BTreeMap<ValidatorPublicKey, ValidatorState>
Returns the validators in this committee, keyed by their public key.
Sourcepub fn validator_addresses(
&self,
) -> impl Iterator<Item = (ValidatorPublicKey, &str)>
pub fn validator_addresses( &self, ) -> impl Iterator<Item = (ValidatorPublicKey, &str)>
Returns an iterator over each validator’s public key and network address.
Sourcepub fn total_votes(&self) -> u64
pub fn total_votes(&self) -> u64
Returns the total number of votes across all validators.
Sourcepub fn policy(&self) -> &ResourceControlPolicy
pub fn policy(&self) -> &ResourceControlPolicy
Returns the resource control policy of this committee.
Sourcepub fn policy_mut(&mut self) -> &mut ResourceControlPolicy
pub fn policy_mut(&mut self) -> &mut ResourceControlPolicy
Returns a mutable reference to this committee’s ResourceControlPolicy.
Trait Implementations§
Source§impl Allocative for Committee
impl Allocative for Committee
Source§impl ContainerType for Committee
impl ContainerType for Committee
Source§async fn resolve_field(&self, ctx: &Context<'_>) -> ServerResult<Option<Value>>
async fn resolve_field(&self, ctx: &Context<'_>) -> ServerResult<Option<Value>>
async_graphql::Value. Read moreSource§async fn find_entity(
&self,
ctx: &Context<'_>,
params: &Value,
) -> ServerResult<Option<Value>>
async fn find_entity( &self, ctx: &Context<'_>, params: &Value, ) -> ServerResult<Option<Value>>
Source§fn collect_all_fields<'a>(
&'a self,
ctx: &ContextBase<'a, &'a Positioned<SelectionSet>>,
fields: &mut Fields<'a>,
) -> Result<(), ServerError>
fn collect_all_fields<'a>( &'a self, ctx: &ContextBase<'a, &'a Positioned<SelectionSet>>, fields: &mut Fields<'a>, ) -> Result<(), ServerError>
Source§impl<'de> Deserialize<'de> for Committee
impl<'de> Deserialize<'de> for Committee
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>,
impl Eq for Committee
impl InputObjectType for Committee
Source§impl InputType for Committee
impl InputType for Committee
Source§type RawValueType = Committee
type RawValueType = Committee
Source§fn create_type_info(registry: &mut Registry) -> String
fn create_type_info(registry: &mut Registry) -> String
Source§fn parse(value: Option<Value>) -> InputValueResult<Self>
fn parse(value: Option<Value>) -> InputValueResult<Self>
Value. None represents undefined.Source§fn as_raw_value(&self) -> Option<&Self::RawValueType>
fn as_raw_value(&self) -> Option<&Self::RawValueType>
Source§fn qualified_type_name() -> String
fn qualified_type_name() -> String
impl ObjectType for Committee
Source§impl OutputType for Committee
impl OutputType for Committee
Source§fn create_type_info(registry: &mut Registry) -> String
fn create_type_info(registry: &mut Registry) -> String
Source§async fn resolve(
&self,
ctx: &ContextSelectionSet<'_>,
_field: &Positioned<Field>,
) -> ServerResult<Value>
async fn resolve( &self, ctx: &ContextSelectionSet<'_>, _field: &Positioned<Field>, ) -> ServerResult<Value>
async_graphql::Value.Source§fn qualified_type_name() -> String
fn qualified_type_name() -> String
impl StructuralPartialEq for Committee
Auto Trait Implementations§
impl Freeze for Committee
impl RefUnwindSafe for Committee
impl Send for Committee
impl Sync for Committee
impl Unpin for Committee
impl UnsafeUnpin for Committee
impl UnwindSafe for Committee
Blanket Implementations§
impl<_INNER> AutoTraits for _INNER
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<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreimpl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSync for Twhere
T: Sync,
impl<T> Post for Twhere
T: Send + 'static,
Source§impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
Source§fn read<'instance>(
&self,
instance: &'instance &mut I,
location: GuestPointer,
length: u32,
) -> Result<Cow<'instance, [u8]>, RuntimeError>
fn read<'instance>( &self, instance: &'instance &mut I, location: GuestPointer, length: u32, ) -> Result<Cow<'instance, [u8]>, RuntimeError>
Reads length bytes from memory from the provided location.
Source§fn write(
&mut self,
instance: &mut &mut I,
location: GuestPointer,
bytes: &[u8],
) -> Result<(), RuntimeError>
fn write( &mut self, instance: &mut &mut I, location: GuestPointer, bytes: &[u8], ) -> Result<(), RuntimeError>
Writes the bytes to memory at the provided location.