Struct linera_chain::ChainStateView
source · pub struct ChainStateView<C>{
pub execution_state: ExecutionStateView<C>,
pub execution_state_hash: RegisterView<C, Option<CryptoHash>>,
pub tip_state: RegisterView<C, ChainTipState>,
pub manager: RegisterView<C, ChainManager>,
pub confirmed_log: LogView<C, CryptoHash>,
pub received_log: LogView<C, ChainAndHeight>,
pub inboxes: ReentrantCollectionView<C, Origin, InboxStateView<C>>,
pub outboxes: ReentrantCollectionView<C, Target, OutboxStateView<C>>,
pub outbox_counters: RegisterView<C, BTreeMap<BlockHeight, u32>>,
pub channels: ReentrantCollectionView<C, ChannelFullName, ChannelStateView<C>>,
}
Expand description
A view accessing the state of a chain.
Fields§
§execution_state: ExecutionStateView<C>
Execution state, including system and user applications.
execution_state_hash: RegisterView<C, Option<CryptoHash>>
Hash of the execution state.
tip_state: RegisterView<C, ChainTipState>
Block-chaining state.
manager: RegisterView<C, ChainManager>
Consensus state.
confirmed_log: LogView<C, CryptoHash>
Hashes of all certified blocks for this sender.
This ends with block_hash
and has length usize::from(next_block_height)
.
received_log: LogView<C, ChainAndHeight>
Sender chain and height of all certified blocks known as a receiver (local ordering).
inboxes: ReentrantCollectionView<C, Origin, InboxStateView<C>>
Mailboxes used to receive messages indexed by their origin.
outboxes: ReentrantCollectionView<C, Target, OutboxStateView<C>>
Mailboxes used to send messages, indexed by their target.
outbox_counters: RegisterView<C, BTreeMap<BlockHeight, u32>>
Number of outgoing messages in flight for each block height.
We use a RegisterView
to prioritize speed for small maps.
channels: ReentrantCollectionView<C, ChannelFullName, ChannelStateView<C>>
Channels able to multicast messages to subscribers.
Implementations§
source§impl<C> ChainStateView<C>
impl<C> ChainStateView<C>
pub async fn execution_state( &self, ctx: &Context<'_> ) -> Result<&ExecutionStateView<C>>
pub async fn execution_state_hash( &self, ctx: &Context<'_> ) -> Result<&RegisterView<C, Option<CryptoHash>>>
pub async fn tip_state( &self, ctx: &Context<'_> ) -> Result<&RegisterView<C, ChainTipState>>
pub async fn manager( &self, ctx: &Context<'_> ) -> Result<&RegisterView<C, ChainManager>>
pub async fn confirmed_log( &self, ctx: &Context<'_> ) -> Result<&LogView<C, CryptoHash>>
pub async fn received_log( &self, ctx: &Context<'_> ) -> Result<&LogView<C, ChainAndHeight>>
pub async fn inboxes( &self, ctx: &Context<'_> ) -> Result<&ReentrantCollectionView<C, Origin, InboxStateView<C>>>
pub async fn outboxes( &self, ctx: &Context<'_> ) -> Result<&ReentrantCollectionView<C, Target, OutboxStateView<C>>>
pub async fn outbox_counters( &self, ctx: &Context<'_> ) -> Result<&RegisterView<C, BTreeMap<BlockHeight, u32>>>
pub async fn channels( &self, ctx: &Context<'_> ) -> Result<&ReentrantCollectionView<C, ChannelFullName, ChannelStateView<C>>>
source§impl<C> ChainStateView<C>
impl<C> ChainStateView<C>
pub fn chain_id(&self) -> ChainId
pub async fn query_application( &mut self, query: Query ) -> Result<Response, ChainError>
pub async fn describe_application( &mut self, application_id: UserApplicationId ) -> Result<UserApplicationDescription, ChainError>
pub async fn mark_messages_as_received( &mut self, target: Target, height: BlockHeight ) -> Result<bool, ChainError>
sourcepub fn all_messages_delivered_up_to(&mut self, height: BlockHeight) -> bool
pub fn all_messages_delivered_up_to(&mut self, height: BlockHeight) -> bool
Returns true if there are no more outgoing messages in flight up to the given block height.
sourcepub fn ensure_is_active(&self) -> Result<(), ChainError>
pub fn ensure_is_active(&self) -> Result<(), ChainError>
Invariant for the states of active chains.
sourcepub async fn validate_incoming_messages(&self) -> Result<(), ChainError>
pub async fn validate_incoming_messages(&self) -> Result<(), ChainError>
Verifies that this chain is up-to-date and all the messages executed ahead of time have been properly received by now.
pub async fn next_block_height_to_receive( &mut self, origin: &Origin ) -> Result<BlockHeight, ChainError>
pub async fn last_anticipated_block_height( &mut self, origin: &Origin ) -> Result<Option<BlockHeight>, ChainError>
sourcepub async fn receive_message_bundle(
&mut self,
origin: &Origin,
bundle: MessageBundle,
local_time: Timestamp
) -> Result<(), ChainError>
pub async fn receive_message_bundle( &mut self, origin: &Origin, bundle: MessageBundle, local_time: Timestamp ) -> Result<(), ChainError>
Attempts to process a new bundle
of messages from the given origin
. Returns an
internal error if the bundle doesn’t appear to be new, based on the sender’s
height. The value local_time
is specific to each validator and only used for
round timeouts.
pub async fn execute_init_message( &mut self, message_id: MessageId, message: &Message, timestamp: Timestamp, local_time: Timestamp ) -> Result<bool, ChainError>
sourcepub async fn remove_events_from_inboxes(
&mut self,
block: &Block
) -> Result<(), ChainError>
pub async fn remove_events_from_inboxes( &mut self, block: &Block ) -> Result<(), ChainError>
Removes the incoming messages in the block from the inboxes.
sourcepub async fn execute_block(
&mut self,
block: &Block,
local_time: Timestamp
) -> Result<BlockExecutionOutcome, ChainError>
pub async fn execute_block( &mut self, block: &Block, local_time: Timestamp ) -> Result<BlockExecutionOutcome, ChainError>
Executes a new block: first the incoming messages, then the main operation.
- Modifies the state of inboxes, outboxes, and channels, if needed.
- As usual, in case of errors,
self
may not be consistent any more and should be thrown away. - Returns the list of messages caused by the block being executed.
Trait Implementations§
source§impl<C> ContainerType for ChainStateView<C>
impl<C> ContainerType for ChainStateView<C>
source§async fn resolve_field(&self, ctx: &Context<'_>) -> ServerResult<Option<Value>>
async fn resolve_field(&self, ctx: &Context<'_>) -> ServerResult<Option<Value>>
async_graphql::Value
. Read moresource§fn collect_all_fields<'a>(
&'a self,
ctx: &ContextBase<'a, &'a Positioned<SelectionSet>>,
fields: &mut Fields<'a>
) -> Result<(), ServerError>
fn collect_all_fields<'a>( &'a self, ctx: &ContextBase<'a, &'a Positioned<SelectionSet>>, fields: &mut Fields<'a> ) -> Result<(), ServerError>
source§fn find_entity(
&self,
_: &ContextBase<'_, &Positioned<Field>>,
_params: &ConstValue
) -> impl Future<Output = Result<Option<ConstValue>, ServerError>> + Send
fn find_entity( &self, _: &ContextBase<'_, &Positioned<Field>>, _params: &ConstValue ) -> impl Future<Output = Result<Option<ConstValue>, ServerError>> + Send
source§impl<C> Debug for ChainStateView<C>
impl<C> Debug for ChainStateView<C>
source§impl<C> OutputType for ChainStateView<C>
impl<C> OutputType for ChainStateView<C>
source§fn create_type_info(registry: &mut Registry) -> String
fn create_type_info(registry: &mut Registry) -> String
source§async fn resolve(
&self,
ctx: &ContextSelectionSet<'_>,
_field: &Positioned<Field>
) -> ServerResult<Value>
async fn resolve( &self, ctx: &ContextSelectionSet<'_>, _field: &Positioned<Field> ) -> ServerResult<Value>
async_graphql::Value
.source§fn qualified_type_name() -> String
fn qualified_type_name() -> String
source§impl<C> RootView<C> for ChainStateView<C>
impl<C> RootView<C> for ChainStateView<C>
source§impl<C> View<C> for ChainStateView<C>
impl<C> View<C> for ChainStateView<C>
source§fn load<'async_trait>(
context: C
) -> Pin<Box<dyn Future<Output = Result<Self, ViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn load<'async_trait>(
context: C
) -> Pin<Box<dyn Future<Output = Result<Self, ViewError>> + Send + 'async_trait>>where
Self: 'async_trait,
source§fn rollback(&mut self)
fn rollback(&mut self)
flush
should have no effect to storage.source§fn flush(&mut self, batch: &mut Batch) -> Result<bool, ViewError>
fn flush(&mut self, batch: &mut Batch) -> Result<bool, ViewError>
batch
variable first. If the view is dropped without calling flush
, staged
changes are simply lost.
The returned boolean indicates whether the operation removes the view or not.