referrerpolicy=no-referrer-when-downgrade

Trait OracleApi

Source
pub trait OracleApi<Block: BlockT, ProviderId, Key, Value>: Core<Block>
where ProviderId: Codec, Key: Codec, Value: Codec,
{ // Provided methods fn get_value( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, provider_id: ProviderId, key: Key, ) -> Result<Option<Value>, ApiError> { ... } fn get_all_values( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, provider_id: ProviderId, ) -> Result<Vec<(Key, Option<Value>)>, ApiError> { ... } }
Expand description

Runtime API for querying oracle data from the blockchain.

This trait provides methods to retrieve oracle data without requiring direct storage access. It’s designed to be called from external clients, RPC nodes, and other blockchain infrastructure components that need access to oracle information.

The API is generic over three type parameters:

  • ProviderId: Identifies the oracle provider or data source
  • Key: The oracle key identifying the specific data feed
  • Value: The oracle data value type

Provided Methods§

Source

fn get_value( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, provider_id: ProviderId, key: Key, ) -> Result<Option<Value>, ApiError>

Retrieves a specific oracle value for a given provider and key.

Returns the current oracle value if available, or None if no data exists for the specified provider and key combination.

§Parameters
  • provider_id: The oracle provider identifier
  • key: The oracle key identifying the data feed
§Returns

Returns Some(value) if oracle data exists, None otherwise.

Source

fn get_all_values( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, provider_id: ProviderId, ) -> Result<Vec<(Key, Option<Value>)>, ApiError>

Retrieves all oracle values for a specific provider.

Returns a vector of key-value pairs containing all available oracle data from the specified provider. Each pair contains the oracle key and its corresponding value (if available).

§Parameters
  • provider_id: The oracle provider identifier
§Returns

Returns a vector of (Key, Option<Value>) pairs representing all oracle data available from the specified provider.

Trait Implementations§

Source§

impl<Block: BlockT, ProviderId, Key, Value> RuntimeApiInfo for dyn OracleApi<Block, ProviderId, Key, Value>

Source§

const ID: [u8; 8]

The identifier of the runtime api.
Source§

const VERSION: u32 = 1u32

The version of the runtime api.

Implementors§