Struct diem_types::trusted_state::TrustedState[][src]

pub struct TrustedState { /* fields omitted */ }
Expand description

TrustedState keeps track of our latest trusted state, including the latest verified version and the latest verified validator set.

Implementations

impl TrustedState[src]

pub fn version(&self) -> Version[src]

pub fn waypoint(&self) -> Waypoint[src]

pub fn verify_and_ratchet<'a>(
    &self,
    latest_li: &'a LedgerInfoWithSignatures,
    epoch_change_proof: &'a EpochChangeProof
) -> Result<TrustedStateChange<'a>>
[src]

Verify and ratchet forward our trusted state using a EpochChangeProof (that moves us into the latest epoch) and a LedgerInfoWithSignatures inside that epoch.

For example, a client sends a GetStateProof request to an upstream FullNode and receives some epoch change proof along with a latest ledger info inside the StateProof response. This function verifies the change proof and ratchets the trusted state version forward if the response successfully moves us into a new epoch or a new latest ledger info within our current epoch.

  • If there was a validation error, e.g., the epoch change proof was invalid, we return an Err.

  • If the message was well formed but stale (i.e., the returned latest ledger is behind our trusted version), we also return an Err since stale responses should always be rejected.

  • If the response is fresh and there is no epoch change, we just ratchet our trusted version to the latest ledger info and return Ok(TrustedStateChange::Version { .. }).

  • If there is a new epoch and the server provides a correct proof, we ratchet our trusted version forward, update our verifier to contain the new validator set, and return Ok(TrustedStateChange::Epoch { .. }).

Trait Implementations

impl Clone for TrustedState[src]

fn clone(&self) -> TrustedState[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for TrustedState[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'de> Deserialize<'de> for TrustedState[src]

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl From<Waypoint> for TrustedState[src]

fn from(waypoint: Waypoint) -> Self[src]

Performs the conversion.

impl PartialEq<TrustedState> for TrustedState[src]

fn eq(&self, other: &TrustedState) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &TrustedState) -> bool[src]

This method tests for !=.

impl Serialize for TrustedState[src]

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
    __S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl TryFrom<&'_ LedgerInfo> for TrustedState[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(ledger_info: &LedgerInfo) -> Result<Self>[src]

Performs the conversion.

impl Eq for TrustedState[src]

impl StructuralEq for TrustedState[src]

impl StructuralPartialEq for TrustedState[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> TestOnlyHash for T where
    T: Serialize + ?Sized
[src]

pub fn test_only_hash(&self) -> HashValue[src]

Generates a hash used only for tests.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]