Struct linera_chain::ChainStateView
source · pub struct ChainStateView<C>{Show 15 fields
pub execution_state: ExecutionStateView<C>,
pub execution_state_hash: RegisterView<C, Option<CryptoHash>>,
pub tip_state: RegisterView<C, ChainTipState>,
pub manager: ChainManager<C>,
pub pending_validated_blobs: PendingBlobsView<C>,
pub pending_proposed_blobs: ReentrantCollectionView<C, Owner, PendingBlobsView<C>>,
pub confirmed_log: LogView<C, CryptoHash>,
pub received_log: LogView<C, ChainAndHeight>,
pub received_certificate_trackers: RegisterView<C, HashMap<ValidatorPublicKey, u64>>,
pub inboxes: ReentrantCollectionView<C, Origin, InboxStateView<C>>,
pub unskippable_bundles: QueueView<C, TimestampedBundleInInbox>,
pub removed_unskippable_bundles: SetView<C, BundleInInbox>,
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: ChainManager<C>
Consensus state.
pending_validated_blobs: PendingBlobsView<C>
Pending validated block that is still missing blobs. The incomplete set of blobs for the pending validated block.
pending_proposed_blobs: ReentrantCollectionView<C, Owner, PendingBlobsView<C>>
The incomplete sets of blobs for upcoming proposals.
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).
received_certificate_trackers: RegisterView<C, HashMap<ValidatorPublicKey, u64>>
The number of received_log
entries we have synchronized, for each validator.
inboxes: ReentrantCollectionView<C, Origin, InboxStateView<C>>
Mailboxes used to receive messages indexed by their origin.
unskippable_bundles: QueueView<C, TimestampedBundleInInbox>
A queue of unskippable bundles, with the timestamp when we added them to the inbox.
removed_unskippable_bundles: SetView<C, BundleInInbox>
Unskippable bundles that have been removed but are still in the queue.
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<&ChainManager<C>>
pub async fn pending_validated_blobs( &self, ctx: &Context<'_>, ) -> Result<&PendingBlobsView<C>>
pub async fn pending_proposed_blobs( &self, ctx: &Context<'_>, ) -> Result<&ReentrantCollectionView<C, Owner, PendingBlobsView<C>>>
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 received_certificate_trackers( &self, ctx: &Context<'_>, ) -> Result<&RegisterView<C, HashMap<ValidatorPublicKey, u64>>>
pub async fn inboxes( &self, ctx: &Context<'_>, ) -> Result<&ReentrantCollectionView<C, Origin, InboxStateView<C>>>
pub async fn unskippable_bundles( &self, ctx: &Context<'_>, ) -> Result<&QueueView<C, TimestampedBundleInInbox>>
pub async fn removed_unskippable_bundles( &self, ctx: &Context<'_>, ) -> Result<&SetView<C, BundleInInbox>>
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>
sourcepub fn chain_id(&self) -> ChainId
pub fn chain_id(&self) -> ChainId
Returns the ChainId
of the chain this ChainStateView
represents.
pub async fn query_application( &mut self, local_time: Timestamp, query: Query, service_runtime_endpoint: Option<&mut ServiceRuntimeEndpoint>, ) -> Result<QueryOutcome, 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(&self, height: BlockHeight) -> bool
pub fn all_messages_delivered_up_to(&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_bundles(&self) -> Result<(), ChainError>
pub async fn validate_incoming_bundles(&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( &self, origin: &Origin, ) -> Result<BlockHeight, ChainError>
pub async fn last_anticipated_block_height( &self, origin: &Origin, ) -> Result<Option<BlockHeight>, ChainError>
sourcepub async fn receive_message_bundle(
&mut self,
origin: &Origin,
bundle: MessageBundle,
local_time: Timestamp,
add_to_received_log: bool,
) -> Result<bool, ChainError>
pub async fn receive_message_bundle( &mut self, origin: &Origin, bundle: MessageBundle, local_time: Timestamp, add_to_received_log: bool, ) -> Result<bool, 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.
Returns true
if incoming Subscribe
messages created new outbox entries.
sourcepub fn update_received_certificate_trackers(
&mut self,
new_trackers: BTreeMap<ValidatorPublicKey, u64>,
)
pub fn update_received_certificate_trackers( &mut self, new_trackers: BTreeMap<ValidatorPublicKey, u64>, )
Updates the received_log
trackers.
sourcepub async fn execute_init_message_from(
&mut self,
block: &ProposedBlock,
local_time: Timestamp,
) -> Result<(), ChainError>
pub async fn execute_init_message_from( &mut self, block: &ProposedBlock, local_time: Timestamp, ) -> Result<(), ChainError>
Verifies that the block’s first message is OpenChain
. Initializes the chain if necessary.
pub fn current_committee(&self) -> Result<(Epoch, &Committee), ChainError>
pub fn ownership(&self) -> &ChainOwnership
sourcepub async fn remove_bundles_from_inboxes(
&mut self,
timestamp: Timestamp,
incoming_bundles: &[IncomingBundle],
) -> Result<(), ChainError>
pub async fn remove_bundles_from_inboxes( &mut self, timestamp: Timestamp, incoming_bundles: &[IncomingBundle], ) -> Result<(), ChainError>
Removes the incoming message bundles in the block from the inboxes.
sourcepub async fn execute_block(
&mut self,
block: &ProposedBlock,
local_time: Timestamp,
round: Option<u32>,
replaying_oracle_responses: Option<Vec<Vec<OracleResponse>>>,
) -> Result<BlockExecutionOutcome, ChainError>
pub async fn execute_block( &mut self, block: &ProposedBlock, local_time: Timestamp, round: Option<u32>, replaying_oracle_responses: Option<Vec<Vec<OracleResponse>>>, ) -> Result<BlockExecutionOutcome, ChainError>
Executes a block: first the incoming messages, then the main operation.
- Modifies the state of 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 outcome of the execution.
Trait Implementations§
source§impl<C> ClonableView<C> for ChainStateView<C>
impl<C> ClonableView<C> for ChainStateView<C>
source§fn clone_unchecked(&mut self) -> Result<Self, ViewError>
fn clone_unchecked(&mut self) -> Result<Self, ViewError>
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§const NUM_INIT_KEYS: usize = 46usize
const NUM_INIT_KEYS: usize = 46usize
source§fn pre_load(context: &C) -> Result<Vec<Vec<u8>>, ViewError>
fn pre_load(context: &C) -> Result<Vec<Vec<u8>>, ViewError>
source§fn post_load(context: C, values: &[Option<Vec<u8>>]) -> Result<Self, ViewError>
fn post_load(context: C, values: &[Option<Vec<u8>>]) -> Result<Self, ViewError>
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 has_pending_changes<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn has_pending_changes<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
true
if flushing this view would result in changes to the persistent 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.impl<C> ObjectType for ChainStateView<C>
Auto Trait Implementations§
impl<C> !Freeze for ChainStateView<C>
impl<C> !RefUnwindSafe for ChainStateView<C>
impl<C> Send for ChainStateView<C>
impl<C> Sync for ChainStateView<C>
impl<C> Unpin for ChainStateView<C>where
C: Unpin,
impl<C> !UnwindSafe for ChainStateView<C>
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
source§impl<T> MockResults for T
impl<T> MockResults for T
§type Results = T
type Results = T
MockInstance
.source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
source§fn read<'instance>(
&self,
instance: &'instance &mut I,
location: GuestPointer,
length: u32,
) -> Result<Cow<'instance, [u8]>, RuntimeError>
fn read<'instance>( &self, instance: &'instance &mut I, location: GuestPointer, length: u32, ) -> Result<Cow<'instance, [u8]>, RuntimeError>
Reads length
bytes from memory from the provided location
.
source§fn write(
&mut self,
instance: &mut &mut I,
location: GuestPointer,
bytes: &[u8],
) -> Result<(), RuntimeError>
fn write( &mut self, instance: &mut &mut I, location: GuestPointer, bytes: &[u8], ) -> Result<(), RuntimeError>
Writes the bytes
to memory at the provided location
.
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.