Party

Struct Party 

Source
pub struct Party<V: Value, VS: ValueSelector<V>> {
    pub id: u64,
    /* private fields */
}
Expand description

A participant in the BPCon protocol responsible for executing ballots.

A Party manages the execution of ballots by communicating with other parties, processing incoming messages, and following the protocol’s steps. It uses an internal state machine to track its progress through the ballot process.

§Communication

  • msg_in_receiver: Receives incoming messages from other parties.
  • msg_out_sender: Sends outgoing messages to other parties.
  • event_receiver: Receives events that drive the ballot process.
  • event_sender: Sends events to trigger actions in the ballot process.

The Party operates within a BPCon configuration and relies on a ValueSelector to choose values during the consensus process. A LeaderElector is used to determine the leader for each ballot.

Fields§

§id: u64

The identifier of this party.

Implementations§

Source§

impl<V: Value, VS: ValueSelector<V>> Party<V, VS>

Source

pub fn new( id: u64, cfg: BPConConfig, value_selector: VS, elector: Box<dyn LeaderElector<V, VS>>, ) -> (Self, UnboundedReceiver<MessagePacket>, UnboundedSender<MessagePacket>)

Creates a new Party instance.

This constructor sets up the party with the given ID, BPCon configuration, value selector, and leader elector. It also initializes communication channels for receiving and sending messages and events.

§Parameters
  • id: The unique identifier for this party.
  • cfg: The BPCon configuration settings.
  • value_selector: The component responsible for selecting values during the consensus process.
  • elector: The component responsible for electing the leader for each ballot.
§Returns
  • A tuple containing:
    • The new Party instance.
    • The UnboundedReceiver for outgoing messages.
    • The UnboundedSender for incoming messages.
Source

pub fn ballot(&self) -> u64

Returns the current ballot number.

Source

pub fn is_launched(&self) -> bool

Checks if the ballot process has been launched.

§Returns
  • true if the ballot is currently active; false otherwise.
Source

pub fn is_stopped(&self) -> bool

Checks if the ballot process has been stopped.

§Returns
  • true if the ballot has finished or failed; false otherwise.
Source

pub fn get_value_selected(&self) -> Option<V>

Retrieves the selected value if the ballot process has finished successfully.

§Returns
  • Some(V) if the ballot reached a consensus and the value was selected.
  • None if the ballot did not reach consensus or is still ongoing.
Source

pub async fn launch_ballot(&mut self) -> Result<V, LaunchBallotError>

Launches the ballot process.

This method initiates the ballot process, advancing through the different phases of the protocol by sending and receiving events and messages. It handles timeouts for each phase and processes incoming messages to update the party’s state.

§Returns
  • Ok(Some(V)): The selected value if the ballot reaches consensus.
  • Ok(None): If the ballot process is terminated without reaching consensus.
  • Err(LaunchBallotError): If an error occurs during the ballot process.

Auto Trait Implementations§

§

impl<V, VS> Freeze for Party<V, VS>
where VS: Freeze, V: Freeze,

§

impl<V, VS> !RefUnwindSafe for Party<V, VS>

§

impl<V, VS> Send for Party<V, VS>
where VS: Send, V: Send,

§

impl<V, VS> !Sync for Party<V, VS>

§

impl<V, VS> Unpin for Party<V, VS>
where VS: Unpin, V: Unpin,

§

impl<V, VS> !UnwindSafe for Party<V, VS>

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to 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.
Source§

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

Source§

fn vzip(self) -> V