pub struct QueryApi<'api> { /* private fields */ }
Implementations§
source§impl<'api> QueryApi<'api>
impl<'api> QueryApi<'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<BoundedVec<[u8; 32]>>
pub async fn under_construction(
&self,
key_0: u32
) -> Result<BoundedVec<[u8; 32]>>
TWOX-NOTE: SegmentIndex
is an increasing integer, so this is okay.
sourcepub async fn initialized(&self) -> Result<Option<Option<[u8; 32]>>>
pub async fn initialized(&self) -> Result<Option<Option<[u8; 32]>>>
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_initialize
, 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).
Trait Implementations§
Auto Trait Implementations§
impl<'api> !RefUnwindSafe for QueryApi<'api>
impl<'api> Send for QueryApi<'api>
impl<'api> Sync for QueryApi<'api>
impl<'api> Unpin for QueryApi<'api>
impl<'api> !UnwindSafe for QueryApi<'api>
Blanket Implementations§
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.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> 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 more§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.