hotstuff_rs::networking::receiving

Struct ProgressMessageBuffer

source
struct ProgressMessageBuffer {
    buffer_capacity: BufferSize,
    buffer: BTreeMap<ViewNumber, VecDeque<(VerifyingKey, ProgressMessage)>>,
    buffer_size: BufferSize,
}
Expand description

Message buffer intended for storing received ProgressMessages for future views. Its size is bounded by its capacity, and when the capacity is reached messages for highest views may be removed.

Fields§

§buffer_capacity: BufferSize§buffer: BTreeMap<ViewNumber, VecDeque<(VerifyingKey, ProgressMessage)>>§buffer_size: BufferSize

Implementations§

source§

impl ProgressMessageBuffer

source

fn new(buffer_capacity: BufferSize) -> Self

Create an empty message buffer.

source

fn insert<M: Into<ProgressMessage> + Cacheable>( &mut self, msg: M, sender: VerifyingKey, ) -> bool

Try inserting the message into the buffer. In case caching the message makes the buffer grow beyond its capacity, this function either:

  1. If the message has the highest view among the views of messages currently in the buffer, then the message is dropped, or
  2. Otherwise, just enough highest-viewed messages are removed from the buffer to make space for the new message.

Returns whether the message was successfully inserted into the buffer.

source

fn get_msg( &mut self, view: &ViewNumber, ) -> Option<(VerifyingKey, ProgressMessage)>

If there are messages for this view in the buffer, remove and return the message at the front of the queue.

source

fn remove_highest_viewed_msgs(&mut self, bytes_to_remove: u64)

Given the number of bytes that need to be removed, removes just enough highest-viewed messages to free up (at least) the required number of bytes in the buffer.

source

fn remove_expired_msgs(&mut self, cur_view: ViewNumber)

Remove all messages for views less than the current view.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V