[−][src]Struct tendermint_light_client::light_client::LightClient
The light client implements a read operation of a header from the blockchain, by communicating with full nodes. As full nodes may be faulty, it cannot trust the received information, but the light client has to check whether the header it receives coincides with the one generated by Tendermint consensus.
In the Tendermint blockchain, the validator set may change with every new block. The staking and unbonding mechanism induces a security model: starting at time of the header, more than two-thirds of the next validators of a new block are correct for the duration of the trusted period. The fault-tolerant read operation is designed for this security model.
Fields
peer: PeerId
The peer id of the peer this client is connected to
options: Options
Options for this light client
Implementations
impl LightClient
[src]
pub fn new(
peer: PeerId,
options: Options,
clock: impl Clock + 'static,
scheduler: impl Scheduler + 'static,
verifier: impl Verifier + 'static,
io: impl Io + 'static
) -> Self
[src]
peer: PeerId,
options: Options,
clock: impl Clock + 'static,
scheduler: impl Scheduler + 'static,
verifier: impl Verifier + 'static,
io: impl Io + 'static
) -> Self
Constructs a new light client
pub fn from_boxed(
peer: PeerId,
options: Options,
clock: Box<dyn Clock>,
scheduler: Box<dyn Scheduler>,
verifier: Box<dyn Verifier>,
io: Box<dyn Io>
) -> Self
[src]
peer: PeerId,
options: Options,
clock: Box<dyn Clock>,
scheduler: Box<dyn Scheduler>,
verifier: Box<dyn Verifier>,
io: Box<dyn Io>
) -> Self
Constructs a new light client from boxed components
pub fn verify_to_highest(
&mut self,
state: &mut State
) -> Result<LightBlock, Error>
[src]
&mut self,
state: &mut State
) -> Result<LightBlock, Error>
Attempt to update the light client to the highest block of the primary node.
Note: This function delegates the actual work to verify_to_target
.
pub fn verify_to_target(
&self,
target_height: Height,
state: &mut State
) -> Result<LightBlock, Error>
[src]
&self,
target_height: Height,
state: &mut State
) -> Result<LightBlock, Error>
Update the light client to a block of the primary node at the given height.
This is the main function and uses the following components:
- The I/O component is called to fetch the next light block. It is the only component that communicates with other nodes.
- The Verifier component checks whether a header is valid and checks if a new light block should be trusted based on a previously verified light block.
- The Scheduler component decides which height to try to verify next, in case the current block pass verification but cannot be trusted yet.
Implements
- [LCV-DIST-SAFE.1]
- [LCV-DIST-LIFE.1]
- [LCV-PRE-TP.1]
- [LCV-POST-LS.1]
- [LCV-INV-TP.1]
Postcondition
- The light store contains a light block that corresponds to a block of the blockchain of
height
target_height
[LCV-POST-LS.1]
Error conditions
- The light store does not contains a trusted light block within the trusting period [LCV-PRE-TP.1]
- If the core verification loop invariant is violated [LCV-INV-TP.1]
- If verification of a light block fails
- If the fetching a light block from the primary node fails
Contracts
Post-condition: ret . is_ok() == > trusted_store_contains_block_at_target_height(state . light_store . as_ref(), target_height,)
pub fn get_or_fetch_block(
&self,
height: Height,
state: &mut State
) -> Result<(LightBlock, Status), Error>
[src]
&self,
height: Height,
state: &mut State
) -> Result<(LightBlock, Status), Error>
Look in the light store for a block from the given peer at the given height,
which has not previously failed verification (ie. its status is not Failed
).
If one cannot be found, fetch the block from the given peer and store
it in the light store with Unverified
status.
Postcondition
- The provider of block that is returned matches the given peer.
Contracts
Post-condition: ret . as_ref() . map(| (lb, _) | lb . provider == self . peer) . unwrap_or(true)
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for LightClient
[src]
impl Send for LightClient
[src]
impl Sync for LightClient
[src]
impl Unpin for LightClient
[src]
impl !UnwindSafe for LightClient
[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>,