[−][src]Struct tendermint_light_client::peer_list::PeerList
A generic container mapping PeerId
s 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]
pub fn transition_invariant(_prev: &PeerList<T>, _next: &PeerList<T>) -> bool
[src]
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]
&mut self,
faulty_witness: PeerId
) -> Option<PeerId>
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]
&mut self,
primary_error: Option<Error>
) -> Result<PeerId, Error>
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
Auto Trait Implementations
impl<T> RefUnwindSafe for PeerList<T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Send for PeerList<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for PeerList<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for PeerList<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for PeerList<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,