[][src]Struct pbft_engine::state::PbftState

pub struct PbftState {
    pub id: PeerId,
    pub seq_num: u64,
    pub view: u64,
    pub chain_head: BlockId,
    pub phase: PbftPhase,
    pub mode: PbftMode,
    pub member_ids: Vec<PeerId>,
    pub f: u64,
    pub idle_timeout: Timeout,
    pub commit_timeout: Timeout,
    pub view_change_timeout: Timeout,
    pub view_change_duration: Duration,
    pub exponential_retry_base: Duration,
    pub exponential_retry_max: Duration,
    pub forced_view_change_interval: u64,
}

Information about the PBFT algorithm's state

Fields

id: PeerId

This node's ID

seq_num: u64

The node's current sequence number

view: u64

The current view

chain_head: BlockId

The block ID of the node's current chain head

phase: PbftPhase

Current phase of the algorithm

mode: PbftMode

Normal operation or view changing

member_ids: Vec<PeerId>

List of members in the PBFT network, including this node

f: u64

The maximum number of faulty nodes in the network

idle_timeout: Timeout

Timer used to make sure the primary publishes blocks in a timely manner. If not, then this node will initiate a view change.

commit_timeout: Timeout

Timer used to make sure the network doesn't get stuck if it fails to commit a block in a reasonable amount of time. If it doesn't commit a block in time, this node will initiate a view change when the timer expires.

view_change_timeout: Timeout

When view changing, timer is used to make sure a valid NewView message is sent by the new primary in a timely manner. If not, this node will start a different view change.

view_change_duration: Duration

The duration of the view change timeout; when a view change is initiated for view v + 1, the timeout will be equal to the view_change_duration; if the timeout expires and the node starts a change to view v + 2, the timeout will be 2 * view_change_duration; etc.

exponential_retry_base: Duration

The base time to use for retrying with exponential backoff

exponential_retry_max: Duration

The maximum time for retrying with exponential backoff

forced_view_change_interval: u64

How many blocks to commit before forcing a view change for fairness

Implementations

impl PbftState[src]

pub fn new(id: PeerId, head_block_num: u64, config: &PbftConfig) -> Self[src]

Construct the initial state for a PBFT node

Panics

  • If the network this node is on does not have enough nodes to be Byzantine fault tolernant

pub fn get_primary_id(&self) -> PeerId[src]

Obtain the ID for the primary node in the network

pub fn get_primary_id_at_view(&self, view: u64) -> PeerId[src]

Obtain the ID for the primary node at the specified view

pub fn is_primary(&self) -> bool[src]

Tell if this node is currently the primary

pub fn is_primary_at_view(&self, view: u64) -> bool[src]

Tell if this node is the primary at the specified view

pub fn switch_phase(
    &mut self,
    desired_phase: PbftPhase
) -> Result<(), PbftError>
[src]

Switch to the desired phase if it is the next phase of the algorithm; if it is not the next phase, return an error

pub fn at_forced_view_change(&self) -> bool[src]

Trait Implementations

impl Debug for PbftState[src]

impl<'de> Deserialize<'de> for PbftState[src]

impl Display for PbftState[src]

impl Serialize for PbftState[src]

Auto Trait Implementations

impl RefUnwindSafe for PbftState

impl Send for PbftState

impl Sync for PbftState

impl Unpin for PbftState

impl UnwindSafe for PbftState

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> UnsafeAny for T where
    T: Any