Skip to main content

LedgerStateQueryClient

Struct LedgerStateQueryClient 

Source
pub struct LedgerStateQueryClient { /* private fields */ }
Expand description

A ledger state query client for querying blockchain state.

This client provides methods for querying various aspects of the Cardano ledger state, such as UTXOs, stake pools, protocol parameters, and governance proposals.

§Example

use ogmios_client::ledger_state_query::LedgerStateQueryClient;
use ogmios_client::connection::ConnectionConfig;

let client = LedgerStateQueryClient::connect(
    ConnectionConfig::default(),
    None
).await?;

// Get current epoch
let epoch = client.epoch().await?;
println!("Current epoch: {}", epoch);

// Get protocol parameters
let params = client.protocol_parameters().await?;
println!("Min fee coefficient: {}", params.min_fee_coefficient);

// Query UTXOs for an address
let utxos = client.utxo_by_addresses(vec!["addr_test1...".to_string()]).await?;
println!("Found {} UTXOs", utxos.len());

client.shutdown().await?;

Implementations§

Source§

impl LedgerStateQueryClient

Source

pub fn new(context: InteractionContext) -> Self

Create a new ledger state query client from an existing context.

Source

pub async fn connect( connection: ConnectionConfig, options: Option<LedgerStateQueryClientOptions>, ) -> Result<Self>

Connect to Ogmios and create a new ledger state query client.

§Arguments
  • connection - Connection configuration.
  • options - Optional client options.
Source

pub fn context(&self) -> &InteractionContext

Get a reference to the interaction context.

Source

pub async fn acquire_ledger_state(&self, point: Option<Point>) -> Result<Slot>

Acquire a ledger state at a specific point.

Source

pub async fn release_ledger_state(&self) -> Result<()>

Release the acquired ledger state.

Source

pub async fn constitution(&self) -> Result<Constitution>

Query the current constitution.

Source

pub async fn epoch(&self) -> Result<Epoch>

Query the current epoch.

Source

pub async fn era_start(&self) -> Result<EraStart>

Query the era start information.

Source

pub async fn era_summaries(&self) -> Result<Vec<EraSummary>>

Query era summaries.

Source

pub async fn genesis_configuration( &self, era: EraWithGenesis, ) -> Result<GenesisConfiguration>

Query genesis configuration for a specific era.

Source

pub async fn governance_proposals( &self, filter: Option<GovernanceProposalFilter>, ) -> Result<Vec<GovernanceProposalState>>

Query governance proposals.

Source

pub async fn ledger_tip(&self) -> Result<Point>

Query the ledger tip.

Source

pub async fn network_tip(&self) -> Result<Tip>

Query the network tip.

Source

pub async fn network_block_height(&self) -> Result<BlockHeight>

Query the network block height.

Source

pub async fn live_stake_distribution( &self, ) -> Result<HashMap<StakePoolId, LiveStakeDistributionEntry>>

Query live stake distribution.

Source

pub async fn network_start_time(&self) -> Result<UtcTime>

Query the network start time.

Source

pub async fn projected_rewards( &self, stake_addresses: Vec<StakeAddress>, ) -> Result<Vec<ProjectedRewards>>

Query projected rewards.

Source

pub async fn protocol_parameters(&self) -> Result<ProtocolParameters>

Query protocol parameters.

Source

pub async fn reward_account_summaries( &self, keys: Vec<StakeAddress>, ) -> Result<HashMap<RewardAccount, RewardAccountSummary>>

Query reward account summaries.

Source

pub async fn stake_pools( &self, filter: Option<StakePoolsFilter>, include_stake: bool, ) -> Result<HashMap<StakePoolId, StakePoolView>>

Query stake pools.

Source

pub async fn stake_pools_performances( &self, ) -> Result<HashMap<StakePoolId, StakePoolPerformance>>

Query stake pool performances.

Source

pub async fn utxo(&self, filter: Option<UtxoFilter>) -> Result<Vec<Utxo>>

Query UTXOs.

Source

pub async fn utxo_by_addresses( &self, addresses: Vec<Address>, ) -> Result<Vec<Utxo>>

Query UTXOs by addresses.

Source

pub async fn utxo_by_output_references( &self, output_references: Vec<TransactionOutputReference>, ) -> Result<Vec<Utxo>>

Query UTXOs by output references.

Source

pub async fn shutdown(&self) -> Result<()>

Shutdown the client.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more