pub struct BabeQueryApi<'api> { /* private fields */ }
Implementations§
Source§impl<'api> BabeQueryApi<'api>
impl<'api> BabeQueryApi<'api>
Sourcepub async fn epoch_index(&self) -> Result<u64>
pub async fn epoch_index(&self) -> Result<u64>
Current epoch index.
Current epoch authorities.
Sourcepub async fn genesis_slot(&self) -> Result<Slot>
pub async fn genesis_slot(&self) -> Result<Slot>
The slot at which the first epoch actually started. This is 0 until the first block of the chain.
Sourcepub async fn current_slot(&self) -> Result<Slot>
pub async fn current_slot(&self) -> Result<Slot>
Current slot number.
Sourcepub async fn randomness(&self) -> Result<[u8; 32]>
pub async fn randomness(&self) -> Result<[u8; 32]>
The epoch randomness for the current epoch.
§Security
This MUST NOT be used for gambling, as it can be influenced by a malicious validator in the short term. It MAY be used in many cryptographic protocols, however, so long as one remembers that this (like everything else on-chain) it is public. For example, it can be used where a number is needed that cannot have been chosen by an adversary, for purposes such as public-coin zero-knowledge proofs.
Sourcepub async fn pending_epoch_config_change(
&self,
) -> Result<Option<NextConfigDescriptor>>
pub async fn pending_epoch_config_change( &self, ) -> Result<Option<NextConfigDescriptor>>
Pending epoch configuration change that will be applied when the next epoch is enacted.
Sourcepub async fn next_randomness(&self) -> Result<[u8; 32]>
pub async fn next_randomness(&self) -> Result<[u8; 32]>
Next epoch randomness.
Next epoch authorities.
Sourcepub async fn segment_index(&self) -> Result<u32>
pub async fn segment_index(&self) -> Result<u32>
Randomness under construction.
We make a trade-off between storage accesses and list length.
We store the under-construction randomness in segments of up to
UNDER_CONSTRUCTION_SEGMENT_LENGTH
.
Once a segment reaches this length, we begin the next one.
We reset all segments and return to 0
at the beginning of every
epoch.
Sourcepub async fn under_construction(&self, key_0: u32) -> Result<Vec<[u8; 32]>>
pub async fn under_construction(&self, key_0: u32) -> Result<Vec<[u8; 32]>>
TWOX-NOTE: SegmentIndex
is an increasing integer, so this is okay.
Sourcepub async fn initialized(&self) -> Result<Option<Option<PreDigest>>>
pub async fn initialized(&self) -> Result<Option<Option<PreDigest>>>
Temporary value (cleared at block finalization) which is Some
if per-block initialization has already been called for current block.
This field should always be populated during block processing unless secondary plain slots are enabled (which don’t contain a VRF output).
It is set in on_finalize
, before it will contain the value from the last block.
Sourcepub async fn epoch_start(&self) -> Result<(u32, u32)>
pub async fn epoch_start(&self) -> Result<(u32, u32)>
The block numbers when the last and current epoch have started, respectively N-1
and
N
.
NOTE: We track this is in order to annotate the block number when a given pool of
entropy was fixed (i.e. it was known to chain observers). Since epochs are defined in
slots, which may be skipped, the block numbers may not line up with the slot numbers.
Sourcepub async fn lateness(&self) -> Result<u32>
pub async fn lateness(&self) -> Result<u32>
How late the current block is compared to its parent.
This entry is populated as part of block execution and is cleaned up on block finalization. Querying this storage entry outside of block execution context should always yield zero.
Sourcepub async fn epoch_config(&self) -> Result<Option<BabeEpochConfiguration>>
pub async fn epoch_config(&self) -> Result<Option<BabeEpochConfiguration>>
The configuration for the current epoch. Should never be None
as it is initialized in
genesis.
Sourcepub async fn next_epoch_config(&self) -> Result<Option<BabeEpochConfiguration>>
pub async fn next_epoch_config(&self) -> Result<Option<BabeEpochConfiguration>>
The configuration for the next epoch, None
if the config will not change
(you can fallback to EpochConfig
instead in that case).
Sourcepub async fn skipped_epochs(&self) -> Result<Vec<(u64, u32)>>
pub async fn skipped_epochs(&self) -> Result<Vec<(u64, u32)>>
A list of the last 100 skipped epochs and the corresponding session index when the epoch was skipped.
This is only used for validating equivocation proofs. An equivocation proof must contains a key-ownership proof for a given session, therefore we need a way to tie together sessions and epoch indices, i.e. we need to validate that a validator was the owner of a given key on a given session, and what the active epoch index was during that session.
Trait Implementations§
Source§impl<'api> Clone for BabeQueryApi<'api>
impl<'api> Clone for BabeQueryApi<'api>
Source§fn clone(&self) -> BabeQueryApi<'api>
fn clone(&self) -> BabeQueryApi<'api>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<'api> Freeze for BabeQueryApi<'api>
impl<'api> !RefUnwindSafe for BabeQueryApi<'api>
impl<'api> Send for BabeQueryApi<'api>
impl<'api> Sync for BabeQueryApi<'api>
impl<'api> Unpin for BabeQueryApi<'api>
impl<'api> !UnwindSafe for BabeQueryApi<'api>
Blanket Implementations§
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<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moreSource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.