[][src]Struct grin_chain::txhashset::HeaderExtension

pub struct HeaderExtension<'a> {
    pub batch: &'a Batch<'a>,
    // some fields omitted
}

A header extension to allow the header MMR to extend beyond the other MMRs individually. This is to allow headers to be validated against the MMR before we have the full block data.

Fields

batch: &'a Batch<'a>

Batch in which the extension occurs, public so it can be used within an extending closure. Just be careful using it that way as it will get rolled back with the extension (i.e on a losing fork).

Methods

impl<'a> HeaderExtension<'a>[src]

pub fn head(&self) -> Tip[src]

The head representing the furthest extent of the current extension.

pub fn get_header_by_height(&self, height: u64) -> Result<BlockHeader, Error>[src]

Get the header at the specified height based on the current state of the header extension. Derives the MMR pos from the height (insertion index) and retrieves the header hash. Looks the header up in the db by hash.

pub fn is_on_current_chain(&self, header: &BlockHeader) -> Result<(), Error>[src]

Compares the provided header to the header in the header MMR at that height. If these match we know the header is on the current chain.

pub fn force_rollback(&mut self)[src]

Force the rollback of this extension, no matter the result.

pub fn apply_header(&mut self, header: &BlockHeader) -> Result<(), Error>[src]

Apply a new header to the header MMR extension. This may be either the header MMR or the sync MMR depending on the extension.

pub fn rewind(&mut self, header: &BlockHeader) -> Result<(), Error>[src]

Rewind the header extension to the specified header. Note the close relationship between header height and insertion index.

pub fn size(&self) -> u64[src]

The size of the header MMR.

pub fn root(&self) -> Result<Hash, Error>[src]

The root of the header MMR for convenience.

pub fn validate_root(&self, header: &BlockHeader) -> Result<(), Error>[src]

Validate the prev_root of the header against the root of the current header MMR.

Auto Trait Implementations

impl<'a> !Send for HeaderExtension<'a>

impl<'a> !Sync for HeaderExtension<'a>

impl<'a> Unpin for HeaderExtension<'a>

impl<'a> !UnwindSafe for HeaderExtension<'a>

impl<'a> !RefUnwindSafe for HeaderExtension<'a>

Blanket Implementations

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

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

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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<T> UnsafeAny for T where
    T: Any

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Erased for T

impl<T> SafeBorrow<T> for T where
    T: ?Sized

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