hotstuff_rs::event_bus

Struct EventHandlers

source
pub(crate) struct EventHandlers {
Show 27 fields pub(crate) insert_block_handlers: HandlerPair<InsertBlockEvent>, pub(crate) commit_block_handlers: HandlerPair<CommitBlockEvent>, pub(crate) prune_block_handlers: HandlerPair<PruneBlockEvent>, pub(crate) update_highest_pc_handlers: HandlerPair<UpdateHighestPCEvent>, pub(crate) update_locked_pc_handlers: HandlerPair<UpdateLockedPCEvent>, pub(crate) update_highest_tc_handlers: HandlerPair<UpdateHighestTCEvent>, pub(crate) update_validator_set_handlers: HandlerPair<UpdateValidatorSetEvent>, pub(crate) propose_handlers: HandlerPair<ProposeEvent>, pub(crate) nudge_handlers: HandlerPair<NudgeEvent>, pub(crate) phase_vote_handlers: HandlerPair<PhaseVoteEvent>, pub(crate) new_view_handlers: HandlerPair<NewViewEvent>, pub(crate) timeout_vote_handlers: HandlerPair<TimeoutVoteEvent>, pub(crate) advance_view_handlers: HandlerPair<AdvanceViewEvent>, pub(crate) receive_proposal_handlers: HandlerPair<ReceiveProposalEvent>, pub(crate) receive_nudge_handlers: HandlerPair<ReceiveNudgeEvent>, pub(crate) receive_phase_vote_handlers: HandlerPair<ReceivePhaseVoteEvent>, pub(crate) receive_new_view_handlers: HandlerPair<ReceiveNewViewEvent>, pub(crate) receive_timeout_vote_handlers: HandlerPair<ReceiveTimeoutVoteEvent>, pub(crate) receive_advance_view_handlers: HandlerPair<ReceiveAdvanceViewEvent>, pub(crate) start_view_handlers: HandlerPair<StartViewEvent>, pub(crate) view_timeout_handlers: HandlerPair<ViewTimeoutEvent>, pub(crate) collect_pc_handlers: HandlerPair<CollectPCEvent>, pub(crate) collect_tc_handlers: HandlerPair<CollectTCEvent>, pub(crate) start_sync_handlers: HandlerPair<StartSyncEvent>, pub(crate) end_sync_handlers: HandlerPair<EndSyncEvent>, pub(crate) receive_sync_request_handlers: HandlerPair<ReceiveSyncRequestEvent>, pub(crate) send_sync_response_handlers: HandlerPair<SendSyncResponseEvent>,
}
Expand description

Stores the HandlerPair of user-defined and optional logging handlers for each pre-defined event type from events.

Fields§

§insert_block_handlers: HandlerPair<InsertBlockEvent>§commit_block_handlers: HandlerPair<CommitBlockEvent>§prune_block_handlers: HandlerPair<PruneBlockEvent>§update_highest_pc_handlers: HandlerPair<UpdateHighestPCEvent>§update_locked_pc_handlers: HandlerPair<UpdateLockedPCEvent>§update_highest_tc_handlers: HandlerPair<UpdateHighestTCEvent>§update_validator_set_handlers: HandlerPair<UpdateValidatorSetEvent>§propose_handlers: HandlerPair<ProposeEvent>§nudge_handlers: HandlerPair<NudgeEvent>§phase_vote_handlers: HandlerPair<PhaseVoteEvent>§new_view_handlers: HandlerPair<NewViewEvent>§timeout_vote_handlers: HandlerPair<TimeoutVoteEvent>§advance_view_handlers: HandlerPair<AdvanceViewEvent>§receive_proposal_handlers: HandlerPair<ReceiveProposalEvent>§receive_nudge_handlers: HandlerPair<ReceiveNudgeEvent>§receive_phase_vote_handlers: HandlerPair<ReceivePhaseVoteEvent>§receive_new_view_handlers: HandlerPair<ReceiveNewViewEvent>§receive_timeout_vote_handlers: HandlerPair<ReceiveTimeoutVoteEvent>§receive_advance_view_handlers: HandlerPair<ReceiveAdvanceViewEvent>§start_view_handlers: HandlerPair<StartViewEvent>§view_timeout_handlers: HandlerPair<ViewTimeoutEvent>§collect_pc_handlers: HandlerPair<CollectPCEvent>§collect_tc_handlers: HandlerPair<CollectTCEvent>§start_sync_handlers: HandlerPair<StartSyncEvent>§end_sync_handlers: HandlerPair<EndSyncEvent>§receive_sync_request_handlers: HandlerPair<ReceiveSyncRequestEvent>§send_sync_response_handlers: HandlerPair<SendSyncResponseEvent>

Implementations§

source§

impl EventHandlers

source

pub(crate) fn new( log: bool, insert_block_handler: Option<Box<dyn Fn(&InsertBlockEvent) + Send>>, commit_block_handler: Option<Box<dyn Fn(&CommitBlockEvent) + Send>>, prune_block_handler: Option<Box<dyn Fn(&PruneBlockEvent) + Send>>, update_highest_pc_handler: Option<Box<dyn Fn(&UpdateHighestPCEvent) + Send>>, update_locked_pc_handler: Option<Box<dyn Fn(&UpdateLockedPCEvent) + Send>>, update_highest_tc_handler: Option<Box<dyn Fn(&UpdateHighestTCEvent) + Send>>, update_validator_set_handler: Option<Box<dyn Fn(&UpdateValidatorSetEvent) + Send>>, propose_handler: Option<Box<dyn Fn(&ProposeEvent) + Send>>, nudge_handler: Option<Box<dyn Fn(&NudgeEvent) + Send>>, phase_vote_handler: Option<Box<dyn Fn(&PhaseVoteEvent) + Send>>, new_view_handler: Option<Box<dyn Fn(&NewViewEvent) + Send>>, timeout_vote_handler: Option<Box<dyn Fn(&TimeoutVoteEvent) + Send>>, advance_view_handler: Option<Box<dyn Fn(&AdvanceViewEvent) + Send>>, receive_proposal_handler: Option<Box<dyn Fn(&ReceiveProposalEvent) + Send>>, receive_nudge_handler: Option<Box<dyn Fn(&ReceiveNudgeEvent) + Send>>, receive_phase_vote_handler: Option<Box<dyn Fn(&ReceivePhaseVoteEvent) + Send>>, receive_new_view_handler: Option<Box<dyn Fn(&ReceiveNewViewEvent) + Send>>, receive_timeout_vote_handler: Option<Box<dyn Fn(&ReceiveTimeoutVoteEvent) + Send>>, receive_advance_view_handler: Option<Box<dyn Fn(&ReceiveAdvanceViewEvent) + Send>>, start_view_handler: Option<Box<dyn Fn(&StartViewEvent) + Send>>, view_timeout_handler: Option<Box<dyn Fn(&ViewTimeoutEvent) + Send>>, collect_pc_handler: Option<Box<dyn Fn(&CollectPCEvent) + Send>>, collect_tc_handler: Option<Box<dyn Fn(&CollectTCEvent) + Send>>, start_sync_handler: Option<Box<dyn Fn(&StartSyncEvent) + Send>>, end_sync_handler: Option<Box<dyn Fn(&EndSyncEvent) + Send>>, receive_sync_request_handler: Option<Box<dyn Fn(&ReceiveSyncRequestEvent) + Send>>, send_sync_response_handler: Option<Box<dyn Fn(&SendSyncResponseEvent) + Send>>, ) -> EventHandlers

Creates the handler pairs for all pre-defined event types from events given the user-defined handlers, and information on whether logging is enabled.

source

pub(crate) fn is_empty(&self) -> bool

Checks if no handlers are defined, i.e., neither user-defined handlers were defined nor logging is enabled.

source

pub(crate) fn fire_handlers(&self, event: Event)

Triggers the execution of each of the two handlers - the user-defined and the logging handler, if defined - for a given event type from events.

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