Skip to main content

Context

Trait Context 

Source
pub trait Context {
    type Runtime: Runtime;

Show 16 methods // Required methods fn clone(&self) -> Self; fn get_logger(&self, module: &'static str) -> Logger; fn host_info(&self) -> &HostInfo; fn key_manager(&self) -> Option<&dyn KeyManager>; fn runtime_header(&self) -> &Header; fn runtime_round_results(&self) -> &RoundResults; fn consensus_state(&self) -> &ConsensusState; fn history(&self) -> &dyn HistoryHost; fn epoch(&self) -> EpochTime; fn max_messages(&self) -> u32; // Provided methods fn should_execute_contracts(&self) -> bool { ... } fn is_allowed_query<R: Runtime>(&self, method: &str) -> bool { ... } fn local_config<T>(&self, key: &str) -> Option<T> where T: Decode { ... } fn runtime_id(&self) -> &Namespace { ... } fn is_confidential(&self) -> bool { ... } fn now(&self) -> u64 { ... }
}
Expand description

Runtime SDK context.

Required Associated Types§

Source

type Runtime: Runtime

Runtime that the context is being invoked in.

Required Methods§

Source

fn clone(&self) -> Self

Clone this context.

Source

fn get_logger(&self, module: &'static str) -> Logger

Returns a logger.

Source

fn host_info(&self) -> &HostInfo

Information about the host environment.

Source

fn key_manager(&self) -> Option<&dyn KeyManager>

The key manager, if the runtime is confidential.

Source

fn runtime_header(&self) -> &Header

Last runtime block header.

Source

fn runtime_round_results(&self) -> &RoundResults

Results of executing the last successful runtime round.

Source

fn consensus_state(&self) -> &ConsensusState

Consensus state.

Source

fn history(&self) -> &dyn HistoryHost

Historical state.

Source

fn epoch(&self) -> EpochTime

Current epoch.

Source

fn max_messages(&self) -> u32

Maximum number of consensus messages that the runtime can emit in this block.

Provided Methods§

Source

fn should_execute_contracts(&self) -> bool

Whether smart contracts should be executed in this context.

Source

fn is_allowed_query<R: Runtime>(&self, method: &str) -> bool

Whether method is an allowed query per policy in the local config.

Source

fn local_config<T>(&self, key: &str) -> Option<T>
where T: Decode,

Returns node operator-provided local configuration.

This method will always return None in Mode::ExecuteTx contexts.

Source

fn runtime_id(&self) -> &Namespace

Runtime ID.

Source

fn is_confidential(&self) -> bool

Whether the context has a key manager available (e.g. the runtime is confidential).

Source

fn now(&self) -> u64

UNIX timestamp of the current block.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§