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 App
s.
§Purpose
The view of the block tree that AppBlockTreeView
provides is special in two important ways to the
correct implementation of the App
trait:
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 ofproduce_block
. - Just before
proposed_block
is executed in the case ofvalidate_block
.
- Just after
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>
impl<'a, K: KVStore> AppBlockTreeView<'a, K>
sourcepub fn block(&self, block: &CryptoHash) -> Result<Option<Block>, BlockTreeError>
pub fn block(&self, block: &CryptoHash) -> Result<Option<Block>, BlockTreeError>
Get block
, if it is currently in the block tree.
sourcepub fn block_height(
&self,
block: &CryptoHash,
) -> Result<Option<BlockHeight>, BlockTreeError>
pub fn block_height( &self, block: &CryptoHash, ) -> Result<Option<BlockHeight>, BlockTreeError>
Get the height of block
, if block
is currently in the block tree.
sourcepub fn block_justify(
&self,
block: &CryptoHash,
) -> Result<PhaseCertificate, BlockTreeError>
pub fn block_justify( &self, block: &CryptoHash, ) -> Result<PhaseCertificate, BlockTreeError>
Get block.justify
, if block
is currently in the block tree.
sourcepub fn block_data_hash(
&self,
block: &CryptoHash,
) -> Result<Option<CryptoHash>, BlockTreeError>
pub fn block_data_hash( &self, block: &CryptoHash, ) -> Result<Option<CryptoHash>, BlockTreeError>
Get block.data_hash
, if block
is currently in the block tree.
sourcepub fn block_data_len(
&self,
block: &CryptoHash,
) -> Result<Option<DataLen>, BlockTreeError>
pub fn block_data_len( &self, block: &CryptoHash, ) -> Result<Option<DataLen>, BlockTreeError>
Get block.data.len()
, if block
is currently in the block tree.
sourcepub fn block_data(
&self,
block: &CryptoHash,
) -> Result<Option<Data>, BlockTreeError>
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.
sourcepub fn block_datum(&self, block: &CryptoHash, datum_index: u32) -> Option<Datum>
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.
sourcepub fn block_at_height(
&self,
height: BlockHeight,
) -> Result<Option<CryptoHash>, BlockTreeError>
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.
sourcepub fn app_state(&'a self, key: &[u8]) -> Option<Vec<u8>>
pub fn app_state(&'a self, key: &[u8]) -> Option<Vec<u8>>
Get the value associated with key
in the current app state.
sourcepub fn validator_set(&self) -> Result<ValidatorSet, BlockTreeError>
pub fn validator_set(&self) -> Result<ValidatorSet, BlockTreeError>
Get the current committed validator set.