hotstuff_rs::block_tree::accessors::app

Struct AppBlockTreeView

source
pub struct AppBlockTreeView<'a, K: KVStore> {
    pub(super) block_tree: &'a BlockTreeSingleton<K>,
    pub(super) pending_ancestors_app_state_updates: Vec<Option<AppStateUpdates>>,
}
Expand description

View of the block tree made available to method calls on Apps.

§Purpose

The view of the block tree that AppBlockTreeView provides is special in two important ways to the correct implementation of the App trait:

  1. AppBlockTreeView presents the App State as it is at a specific “point in time”, that is:
    • Just after parent_block is executed in the case of produce_block.
    • Just before proposed_block is executed in the case of validate_block.
  2. AppBlockTreeView does not implement all of the block tree getters available through, e.g., BlockTreeSnapshot. Instead, AppBlockTreeView’s getters are limited to those that get the fields of the block tree that should be consistent across all replicas at a specific point in time. App methods can therefore safely depend on the data in these fields without risking non-determinism.

§Constructor

To create an instance of AppBlockTreeView, use [BlockTree::app_view].

Fields§

§block_tree: &'a BlockTreeSingleton<K>§pending_ancestors_app_state_updates: Vec<Option<AppStateUpdates>>

Implementations§

source§

impl<'a, K: KVStore> AppBlockTreeView<'a, K>

source

pub fn block(&self, block: &CryptoHash) -> Result<Option<Block>, BlockTreeError>

Get block, if it is currently in the block tree.

source

pub fn block_height( &self, block: &CryptoHash, ) -> Result<Option<BlockHeight>, BlockTreeError>

Get the height of block, if block is currently in the block tree.

source

pub fn block_justify( &self, block: &CryptoHash, ) -> Result<PhaseCertificate, BlockTreeError>

Get block.justify, if block is currently in the block tree.

source

pub fn block_data_hash( &self, block: &CryptoHash, ) -> Result<Option<CryptoHash>, BlockTreeError>

Get block.data_hash, if block is currently in the block tree.

source

pub fn block_data_len( &self, block: &CryptoHash, ) -> Result<Option<DataLen>, BlockTreeError>

Get block.data.len(), if block is currently in the block tree.

source

pub fn block_data( &self, block: &CryptoHash, ) -> Result<Option<Data>, BlockTreeError>

Get the whole of block.data, if block is currently in the block tree.

source

pub fn block_datum(&self, block: &CryptoHash, datum_index: u32) -> Option<Datum>

Get one block.data[datum_index], if block is currently in the block tree.

source

pub fn block_at_height( &self, height: BlockHeight, ) -> Result<Option<CryptoHash>, BlockTreeError>

Get the committed block at height, if it is currently in the block tree.

source

pub fn app_state(&'a self, key: &[u8]) -> Option<Vec<u8>>

Get the value associated with key in the current app state.

source

pub fn validator_set(&self) -> Result<ValidatorSet, BlockTreeError>

Get the current committed validator set.

Auto Trait Implementations§

§

impl<'a, K> Freeze for AppBlockTreeView<'a, K>

§

impl<'a, K> RefUnwindSafe for AppBlockTreeView<'a, K>
where K: RefUnwindSafe,

§

impl<'a, K> Send for AppBlockTreeView<'a, K>
where K: Sync,

§

impl<'a, K> Sync for AppBlockTreeView<'a, K>
where K: Sync,

§

impl<'a, K> Unpin for AppBlockTreeView<'a, K>

§

impl<'a, K> UnwindSafe for AppBlockTreeView<'a, K>
where K: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V