pub type DigestItem = DigestItem;
Expand description
The item of a block digest.
Aliased Type§
enum DigestItem {
PreRuntime([u8; 4], Vec<u8>),
Consensus([u8; 4], Vec<u8>),
Seal([u8; 4], Vec<u8>),
Other(Vec<u8>),
RuntimeEnvironmentUpdated,
}
Variants§
PreRuntime([u8; 4], Vec<u8>)
A pre-runtime digest.
These are messages from the consensus engine to the runtime, although the consensus engine can (and should) read them itself to avoid code and state duplication. It is erroneous for a runtime to produce these, but this is not (yet) checked.
NOTE: the runtime is not allowed to panic or fail in an on_initialize
call if an expected PreRuntime
digest is not present. It is the
responsibility of a external block verifier to check this. Runtime API calls
will initialize the block without pre-runtime digests, so initialization
cannot fail when they are missing.
Consensus([u8; 4], Vec<u8>)
A message from the runtime to the consensus engine. This should never be generated by the native code of any consensus engine, but this is not checked (yet).
Seal([u8; 4], Vec<u8>)
Put a Seal on it. This is only used by native code, and is never seen by runtimes.
Other(Vec<u8>)
Some other thing. Unsupported and experimental.
RuntimeEnvironmentUpdated
An indication for the light clients that the runtime execution environment is updated.
Currently this is triggered when:
- Runtime code blob is changed or
heap_pages
value is changed.
Implementations
§impl DigestItem
impl DigestItem
pub fn dref(&self) -> DigestItemRef<'_>
pub fn dref(&self) -> DigestItemRef<'_>
Returns a ‘referencing view’ for this digest item.
pub fn as_pre_runtime(&self) -> Option<([u8; 4], &[u8])>
pub fn as_pre_runtime(&self) -> Option<([u8; 4], &[u8])>
Returns Some
if this entry is the PreRuntime
entry.
pub fn as_consensus(&self) -> Option<([u8; 4], &[u8])>
pub fn as_consensus(&self) -> Option<([u8; 4], &[u8])>
Returns Some
if this entry is the Consensus
entry.
pub fn try_as_raw(&self, id: OpaqueDigestItemId<'_>) -> Option<&[u8]>
pub fn try_as_raw(&self, id: OpaqueDigestItemId<'_>) -> Option<&[u8]>
Returns the opaque data contained in the item if Some
if this entry has the id given.
pub fn try_to<T>(&self, id: OpaqueDigestItemId<'_>) -> Option<T>where
T: Decode,
pub fn try_to<T>(&self, id: OpaqueDigestItemId<'_>) -> Option<T>where
T: Decode,
Returns the data decoded as T
, if the id
is matching.
pub fn seal_try_to<T>(&self, id: &[u8; 4]) -> Option<T>where
T: Decode,
pub fn seal_try_to<T>(&self, id: &[u8; 4]) -> Option<T>where
T: Decode,
Try to match this to a Self::Seal
, check id
matches and decode it.
Returns None
if this isn’t a seal item, the id
doesn’t match or when the decoding fails.
pub fn consensus_try_to<T>(&self, id: &[u8; 4]) -> Option<T>where
T: Decode,
pub fn consensus_try_to<T>(&self, id: &[u8; 4]) -> Option<T>where
T: Decode,
Try to match this to a Self::Consensus
, check id
matches and decode it.
Returns None
if this isn’t a consensus item, the id
doesn’t match or
when the decoding fails.
pub fn pre_runtime_try_to<T>(&self, id: &[u8; 4]) -> Option<T>where
T: Decode,
pub fn pre_runtime_try_to<T>(&self, id: &[u8; 4]) -> Option<T>where
T: Decode,
Try to match this to a Self::PreRuntime
, check id
matches and decode it.
Returns None
if this isn’t a pre-runtime item, the id
doesn’t match or
when the decoding fails.