pub struct MessageRoundState { /* private fields */ }Expand description
A struct to keep track of senders and the cumulative weight of their messages.
MessageRoundState is used to monitor the participants who have sent messages and to accumulate
the total weight of these messages. This helps in determining when a quorum has been reached.
Implementations§
Source§impl MessageRoundState
impl MessageRoundState
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty MessageRoundState.
This method initializes an empty state with no senders and zero weight.
§Returns
A new MessageRoundState instance.
Sourcepub fn get_weight(&self) -> u128
pub fn get_weight(&self) -> u128
Returns the cumulative weight of all messages received in this round.
§Returns
The total weight of all messages that have been added to this state.
Sourcepub fn add_sender(&mut self, sender: u64, weight: u128)
pub fn add_sender(&mut self, sender: u64, weight: u128)
Adds a sender and their corresponding weight to the state.
This method updates the state to include the specified sender and increments the cumulative weight by the specified amount.
§Parameters
sender: The ID of the participant sending the message.weight: The weight associated with this sender’s message.
Sourcepub fn contains_sender(&self, sender: &u64) -> bool
pub fn contains_sender(&self, sender: &u64) -> bool
Trait Implementations§
Source§impl Clone for MessageRoundState
impl Clone for MessageRoundState
Source§fn clone(&self) -> MessageRoundState
fn clone(&self) -> MessageRoundState
Returns a duplicate 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 MessageRoundState
impl Debug for MessageRoundState
Source§impl Default for MessageRoundState
impl Default for MessageRoundState
Source§fn default() -> MessageRoundState
fn default() -> MessageRoundState
Returns the “default value” for a type. Read more
Source§impl PartialEq for MessageRoundState
impl PartialEq for MessageRoundState
impl Eq for MessageRoundState
impl StructuralPartialEq for MessageRoundState
Auto Trait Implementations§
impl Freeze for MessageRoundState
impl RefUnwindSafe for MessageRoundState
impl Send for MessageRoundState
impl Sync for MessageRoundState
impl Unpin for MessageRoundState
impl UnwindSafe for MessageRoundState
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<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>
Gets the layout of the type.