[−][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(&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
Auto Trait Implementations
impl !RefUnwindSafe for Supervisor
[src]
impl Send for Supervisor
[src]
impl Sync for Supervisor
[src]
impl Unpin for Supervisor
[src]
impl !UnwindSafe for Supervisor
[src]
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, 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>,