[][src]Struct tendermint_light_client::peer_list::PeerList

pub struct PeerList<T> { /* fields omitted */ }

A generic container mapping PeerIds to some type T, which keeps track of the primary peer, witnesses, full nodes, and faulty nodes. Provides lifecycle methods to swap the primary, mark witnesses as faulty, and maintains an invariant for correctness.

Implementations

impl<T> PeerList<T>[src]

pub fn invariant(peer_list: &PeerList<T>) -> bool[src]

Invariant maintained by a PeerList

Implements

  • [LCD-INV-NODES]

pub fn transition_invariant(_prev: &PeerList<T>, _next: &PeerList<T>) -> bool[src]

Transition invariant maintained by a PeerList

Implements

  • [LCD-INV-NODES]

pub fn builder() -> PeerListBuilder<T>[src]

Returns a builder of PeerList

pub fn get(&self, peer_id: &PeerId) -> Option<&T>[src]

Get a reference to the light client instance for the given peer id.

pub fn get_mut(&mut self, peer_id: &PeerId) -> Option<&mut T>[src]

Get a mutable reference to the light client instance for the given peer id.

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

Get current primary peer id.

pub fn primary(&self) -> &T[src]

Get a reference to the current primary instance.

pub fn primary_mut(&mut self) -> &mut T[src]

Get a mutable reference to the current primary instance.

pub fn witnesses_ids(&self) -> &BTreeSet<PeerId>[src]

Get all the witnesses peer ids

pub fn full_nodes_ids(&self) -> &BTreeSet<PeerId>[src]

Get all the full nodes peer ids

pub fn faulty_nodes_ids(&self) -> &BTreeSet<PeerId>[src]

Get all the faulty nodes peer ids

pub fn replace_faulty_witness(
    &mut self,
    faulty_witness: PeerId
) -> Option<PeerId>
[src]

Remove the given peer from the list of witnesses, and mark it as faulty. Get a new witness from the list of full nodes, if there are any left. Returns the new witness, if any.

Precondition

  • The given peer id must not be the primary peer id.
  • The given peer must be in the witness list

Contracts

Pre-condition: faulty_witness != self . primary && self . witnesses . contains(& faulty_witness)

Post-condition: Self :: invariant(& self)

pub fn replace_faulty_primary(
    &mut self,
    primary_error: Option<Error>
) -> Result<PeerId, Error>
[src]

Mark the primary as faulty and swap it for the next available witness, if any. Returns the new primary on success.

Errors

  • If there are no witness left, returns ErrorKind::NoWitnessLeft.

Contracts

Post-condition: ret . is_ok() == > Self :: invariant(& self)

pub fn values(&self) -> &HashMap<PeerId, T>[src]

Get a reference to the underlying HashMap

pub fn into_values(self) -> HashMap<PeerId, T>[src]

Consume into the underlying HashMap

Trait Implementations

impl<T: Clone> Clone for PeerList<T>[src]

impl<T: Debug> Debug for PeerList<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for PeerList<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for PeerList<T> where
    T: Send
[src]

impl<T> Sync for PeerList<T> where
    T: Sync
[src]

impl<T> Unpin for PeerList<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for PeerList<T> where
    T: UnwindSafe
[src]

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> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

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

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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<V, T> VZip<V> for T where
    V: MultiLane<T>,