Struct mixnet::request_manager::RequestManager
source · pub struct RequestManager<R> { /* private fields */ }
Expand description
Request manager state. The user is responsible for calling
update_session_status
,
process_post_queues
, and
pop_next_retry
at the appropriate times to make progress.
Implementations§
source§impl<C, R: Request<Context = C>> RequestManager<R>
impl<C, R: Request<Context = C>> RequestManager<R>
sourcepub fn update_session_status<X>(
&mut self,
mixnet: &mut Mixnet<X>,
ns: &dyn NetworkStatus,
context: &C,
)
pub fn update_session_status<X>( &mut self, mixnet: &mut Mixnet<X>, ns: &dyn NetworkStatus, context: &C, )
Update the current session index and phase. This should be called after
Mixnet::set_session_status
. This may post messages to mixnet
.
sourcepub fn insert<X>(
&mut self,
request: R,
mixnet: &mut Mixnet<X>,
ns: &dyn NetworkStatus,
context: &C,
)
pub fn insert<X>( &mut self, request: R, mixnet: &mut Mixnet<X>, ns: &dyn NetworkStatus, context: &C, )
Insert a request. This should only be called if there is space (see
has_space
). This may post messages to mixnet
.
A request is only removed when:
remove
is called with the corresponding message ID. This would typically happen when a reply is received.- An unrecoverable error is encountered while posting to the mixnet. In this case,
Request::handle_post_err
is called. - The retry limit is reached. In this case,
Request::handle_retry_limit_reached
is called.
sourcepub fn remove(&mut self, message_id: &MessageId) -> Option<R>
pub fn remove(&mut self, message_id: &MessageId) -> Option<R>
Remove a request. Typically this would be called when a reply is received. Returns None
if there is no request with the given message ID.
sourcepub fn process_post_queues<X>(
&mut self,
mixnet: &mut Mixnet<X>,
ns: &dyn NetworkStatus,
context: &C,
)
pub fn process_post_queues<X>( &mut self, mixnet: &mut Mixnet<X>, ns: &dyn NetworkStatus, context: &C, )
Attempt to post messages from the internal post queues to mixnet
. This should be called
when the
SPACE_IN_AUTHORED_PACKET_QUEUE
event fires.
sourcepub fn next_retry_deadline(&self) -> Option<Instant>
pub fn next_retry_deadline(&self) -> Option<Instant>
Returns the next instant at which pop_next_retry
should be
called.
sourcepub fn pop_next_retry<X>(
&mut self,
mixnet: &mut Mixnet<X>,
ns: &dyn NetworkStatus,
context: &C,
) -> bool
pub fn pop_next_retry<X>( &mut self, mixnet: &mut Mixnet<X>, ns: &dyn NetworkStatus, context: &C, ) -> bool
Pop the next request from the internal retry queue. This should be called whenever the
deadline returned by next_retry_deadline
is reached. This
may post messages to mixnet
. Returns false
if the internal retry queue is empty.
sourcepub fn next_retry_deadline_changed(&mut self) -> bool
pub fn next_retry_deadline_changed(&mut self) -> bool
Returns true
if the next retry deadline (see
next_retry_deadline
) has changed since the last call.