[][src]Struct tendermint_light_client::supervisor::Supervisor

pub struct Supervisor { /* fields omitted */ }

The supervisor manages multiple light client instances, of which one is deemed to be the primary instance through which blocks are retrieved and verified. The other instances are considered as witnesses which are consulted to perform fork detection.

If primary verification fails, the primary client is removed and a witness is promoted to primary. If a witness is deemed faulty, then the witness is removed.

The supervisor is intended to be ran in its own thread, and queried via a Handle.

Example

This example is not tested
let mut supervisor: Supervisor = todo!();
let mut handle = supervisor.handle();

// Spawn the supervisor in its own thread.
std::thread::spawn(|| supervisor.run());

loop {
    // Asynchronously query the supervisor via a handle
    let maybe_block = handle.verify_to_highest();
    match maybe_block {
        Ok(light_block) => {
            println!("[info] synced to block {}", light_block.height());
        }
        Err(e) => {
            println!("[error] sync failed: {}", e);
        }
    };

    std::thread::sleep(Duration::from_millis(800));
}

Implementations

impl Supervisor[src]

pub fn new(
    peers: PeerList<Instance>,
    fork_detector: impl ForkDetector + 'static,
    evidence_reporter: impl EvidenceReporter + 'static
) -> Self
[src]

Constructs a new supevisor from the given list of peers and fork detector instance.

pub fn handle(&self) -> SupervisorHandle[src]

Create a new handle to this supervisor.

pub fn latest_trusted(&self) -> Option<LightBlock>[src]

Get the latest trusted state of the primary peer, if any

pub fn verify_to_highest(&mut self) -> Result<LightBlock, Error>[src]

Verify to the highest block.

pub fn verify_to_target(&mut self, height: Height) -> Result<LightBlock, Error>[src]

Verify to the block at the given height.

pub fn run(self) -> Result<(), Error>[src]

Run the supervisor event loop in the same thread.

This method should typically be called within a new thread with std::thread::spawn.

Trait Implementations

impl Debug for Supervisor[src]

Auto Trait Implementations

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, 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>,