[−][src]Struct tendermint_light_client::supervisor::Supervisor
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
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]
peers: PeerList<Instance>,
fork_detector: impl ForkDetector + 'static,
evidence_reporter: impl EvidenceReporter + 'static
) -> Self
Constructs a new supevisor from the given list of peers and fork detector instance.
pub fn handle(&mut self) -> impl Handle
[src]
Create a new handle to this supervisor.
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
Auto Trait Implementations
impl !RefUnwindSafe for Supervisor
impl Send for Supervisor
impl !Sync for Supervisor
impl Unpin for Supervisor
impl !UnwindSafe for Supervisor
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
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.
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>,