Struct Client

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

A client for gRPC API v2 of the Concordium node. Can be used to control the node, send transactions and query information about the node and the state of the chain.

§Connecting to a Concordium node

Creates a new client connection to a Concordium node. Make sure to have access to the gRPC API v2 endpoint of a running node.

use concordium_rust_sdk::v2::{Client, Endpoint};
use std::str::FromStr;

// Assumes the node is running locally and gRPC API v2 can be accessed on port 20001.
let node_endpoint = Endpoint::from_str("http://localhost:20001")?;
let mut client = Client::new(node_endpoint).await?;

// Verify the connection to the node by printing node information.
let node_info = client.get_node_info().await?;
println!("{:#?}", node_info);

§Concurrent use of the client

All endpoints take a &mut self as an argument which means that a single instance cannot be used concurrently. However instead of putting the Client behind a Mutex, the intended way to use it is to clone it. Cloning is very cheap and will reuse the underlying connection.

Implementations§

Source§

impl Client

Source

pub async fn new<E>(endpoint: E) -> Result<Self, Error>
where E: TryInto<Endpoint>, E::Error: Into<Box<dyn Error + Send + Sync + 'static>>,

Construct a new client connection to a concordium node.

§Example

Creates a new client. Note the example assumes access to a local running node.

use concordium_rust_sdk::{endpoints::Endpoint, v2::Client};
use std::str::FromStr;

let mut client = Client::new("http://localhost:20001").await?;
Source

pub async fn get_account_info( &mut self, acc: &AccountIdentifier, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<AccountInfo>>

Get the information for the given account in the given block. If either the block or the account do not exist QueryError::NotFound is returned.

Source

pub async fn get_next_account_sequence_number( &mut self, account_address: &AccountAddress, ) -> QueryResult<AccountNonceResponse>

Get the next sequence number for the account, with information on how reliable the information is.

Source

pub async fn get_consensus_info(&mut self) -> QueryResult<ConsensusInfo>

Get information about the current state of consensus. This is an overview of the node’s current view of the chain.

Source

pub async fn get_cryptographic_parameters( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<CryptographicParameters>>

Get the currently used cryptographic parameters. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn get_account_list( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<AccountAddress, Status>>>>

Get the list of accounts in the given block. The stream will end when all accounts that exist in the state at the end of the given block have been returned. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn get_module_list( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<ModuleReference, Status>>>>

Get a list of all smart contract modules. The stream will end when all modules that exist in the state at the end of the given block have been returned. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn get_module_source( &mut self, module_ref: &ModuleReference, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<WasmModule>>

Get the source of a smart contract module. If the block or module does not exist QueryError::NotFound is returned.

Source

pub async fn get_instance_list( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<ContractAddress, Status>>>>

Get the list of smart contract instances in a given block. The stream will end when all instances that exist in the state at the end of the given block have been returned. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn get_instance_info( &mut self, address: ContractAddress, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<InstanceInfo>>

Get information about a smart contract instance as it appears at the end of the given block. If the block or instance does not exist QueryError::NotFound is returned.

Source

pub async fn get_ancestors( &mut self, bi: impl IntoBlockIdentifier, limit: u64, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<BlockHash, Status>>>>

Get a stream of ancestors for the provided block. Starting with the provided block itself, moving backwards until no more ancestors or the requested number of ancestors have been returned.

Source

pub async fn get_finalized_blocks( &mut self, ) -> QueryResult<impl Stream<Item = Result<FinalizedBlockInfo, Status>>>

Return a stream of blocks that are finalized from the time the query is made onward. This can be used to listen for newly finalized blocks.

Note: There is no guarantee that blocks will not be skipped if the client is too slow in processing the stream, however blocks will always be sent by increasing block height.

Source

pub async fn get_instance_state( &mut self, ca: ContractAddress, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<(Vec<u8>, Vec<u8>), Status>>>>

Get the exact state of a specific contract instance, streamed as a list of key-value pairs. The list is streamed in lexicographic order of keys. If the block or instance does not exist QueryError::NotFound is returned.

Source

pub async fn instance_state_lookup( &mut self, ca: ContractAddress, key: impl Into<Vec<u8>>, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<Vec<u8>>>

Get the value at a specific key of a contract state. In contrast to get_instance_state this is more efficient, but requires the user to know the specific key to look for. If the block or instance does not exist QueryError::NotFound is returned.

Source

pub async fn get_block_item_status( &mut self, th: &TransactionHash, ) -> QueryResult<TransactionStatus>

Get the status of and information about a specific block item (transaction). If the block item does not exist QueryError::NotFound is returned.

Source

pub async fn send_block_item<P: PayloadLike>( &mut self, bi: &BlockItem<P>, ) -> RPCResult<TransactionHash>

Send a block item. A block item is either an AccountTransaction, which is a transaction signed and paid for by an account, a CredentialDeployment, which creates a new account, or UpdateInstruction, which is an instruction to change some parameters of the chain. Update instructions can only be sent by the governance committee.

Source

pub async fn send_account_transaction<P: PayloadLike>( &mut self, at: AccountTransaction<P>, ) -> RPCResult<TransactionHash>

Send an account transaction. This is just a helper around send_block_item block item for convenience.

Source

pub async fn get_account_transaction_sign_hash( &mut self, header: &TransactionHeader, payload: &Payload, ) -> RPCResult<TransactionSignHash>

Get the hash to be signed for an account transaction from the node. The hash returned can then be used for signing when constructing TransactionSignature as part of calling Client::send_block_item.

This is provided as a convenience to support cases where the right SDK is not available for interacting with the node.

This SDK can compute the hash off-line and it is not recommended to use this endpoint, instead use compute_transaction_sign_hash.

Source

pub async fn wait_until_finalized( &mut self, hash: &TransactionHash, ) -> QueryResult<(BlockHash, BlockItemSummary)>

Wait until the transaction is finalized. Returns NotFound in case the transaction is not known to the node. In case of success, the return value is a pair of the block hash of the block that contains the transactions, and its outcome in the block.

Since this can take an indefinite amount of time in general, users of this function might wish to wrap it inside timeout handler and handle the resulting failure.

Source

pub async fn invoke_instance( &mut self, bi: impl IntoBlockIdentifier, context: &ContractContext, ) -> QueryResult<QueryResponse<InvokeContractResult>>

Run the smart contract instance entrypoint in a given context and in the state at the end of the given block and return the results. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn begin_dry_run(&mut self) -> QueryResult<DryRun>

Start a dry-run sequence that can be used to simulate a series of transactions and other operations on the node.

Before invoking any other operations on the dry_run::DryRun object, the state must be loaded by calling dry_run::DryRun::load_block_state.

Source

pub async fn dry_run( &mut self, bi: impl IntoBlockIdentifier, ) -> DryRunResult<(DryRun, BlockStateLoaded)>

Start a dry-run sequence that can be used to simulate a series of transactions and other operations on the node, starting from the specified block.

Source

pub async fn get_block_info( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<BlockInfo>>

Get information, such as height, timings, and transaction counts for the given block. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn is_payday_block( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<bool>>

Get information about whether a block identified by bi is a payday block or not. This will always return false for blocks produced prior to protocol version 4. If the block does not exits QueryError::NotFound is returned.

Source

pub async fn get_baker_list( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<BakerId, Status>>>>

Get all the bakers at the end of the given block. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn get_pool_info( &mut self, block_id: impl IntoBlockIdentifier, baker_id: BakerId, ) -> QueryResult<QueryResponse<BakerPoolStatus>>

Get information about a given pool at the end of a given block. If the block does not exist or is prior to protocol version 4 then QueryError::NotFound is returned.

Source

pub async fn get_passive_delegation_info( &mut self, block_id: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<PassiveDelegationStatus>>

Get information about the passive delegators at the end of a given block. If the block does not exist or is prior to protocol version 4 then QueryError::NotFound is returned.

Source

pub async fn get_blocks_at_height( &mut self, blocks_at_height_input: &BlocksAtHeightInput, ) -> QueryResult<Vec<BlockHash>>

Get a list of live blocks at a given height.

Source

pub async fn get_tokenomics_info( &mut self, block_id: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<RewardsOverview>>

Get information about tokenomics at the end of a given block. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn get_pool_delegators( &mut self, bi: impl IntoBlockIdentifier, baker_id: BakerId, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<DelegatorInfo, Status>>>>

Get the registered delegators of a given pool at the end of a given block. If the block or baker ID does not exist QueryError::NotFound is returned, and if the block is baked prior to protocol version 4 QueryError::RPCError with status Code::InvalidArgument is returned. The stream will end when all the delegators have been returned for the given block.

In contrast to the Client::get_pool_delegators_reward_period which returns delegators that are fixed for the reward period of the block, this endpoint returns the list of delegators that are registered in the block. Any changes to delegators are immediately visible in this list.

Source

pub async fn get_pool_delegators_reward_period( &mut self, bi: impl IntoBlockIdentifier, baker_id: BakerId, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<DelegatorRewardPeriodInfo, Status>>>>

Get the fixed delegators of a given pool for the reward period of the given block. If the block or baker ID does not exist QueryError::NotFound is returned, and if the block is baked prior to protocol version 4 QueryError::RPCError with status Code::InvalidArgument is returned. The stream will end when all the delegators have been returned.

In contrast to the Client::get_pool_delegators which returns delegators registered for the given block, this endpoint returns the fixed delegators contributing stake in the reward period containing the given block.

Source

pub async fn get_passive_delegators( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<DelegatorInfo, Status>>>>

Get the registered passive delegators at the end of a given block. If the block does not exist QueryError::NotFound is returned, and if the block is baked prior to protocol version 4 [QueryError:: RPCError] with status Code::InvalidArgument is returned. The stream will end when all the delegators have been returned.

In contrast to the Client::get_passive_delegators_reward_period which returns delegators that are fixed for the reward period of the block, this endpoint returns the list of delegators that are registered in the block. Any changes to delegators are immediately visible in this list.

Source

pub async fn get_passive_delegators_reward_period( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<DelegatorRewardPeriodInfo, Status>>>>

Get the fixed passive delegators for the reward period of the given block. If the block does not exist QueryError::NotFound is returned. If the block is baked prior to protocol version 4, QueryError::RPCError with status Code::InvalidArgument is returned. The stream will end when all the delegators have been returned.

In contrast to the GetPassiveDelegators which returns delegators registered for the given block, this endpoint returns the fixed delegators contributing stake in the reward period containing the given block.

Source

pub async fn get_branches(&mut self) -> QueryResult<Branch>

Get the current branches of blocks starting from and including the last finalized block.

Branches are all live blocks that are successors of the last finalized block. In particular this means that blocks which do not have a parent are not included in this response.

Source

pub async fn get_election_info( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<BirkParameters>>

Get information related to the baker election for a particular block. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn get_identity_providers( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<IpInfo<IpPairing>, Status>>>>

Get the identity providers registered as of the end of a given block. If the block does not exist QueryError::NotFound is returned. The stream will end when all the identity providers have been returned.

Source

pub async fn get_anonymity_revokers( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<ArInfo<ArCurve>, Status>>>>

Get the list of anonymity revokers in the given block. If the block does not exist QueryError::NotFound is returned. The stream will end when all the anonymity revokers have been returned.

Source

pub async fn get_account_non_finalized_transactions( &mut self, account_address: &AccountAddress, ) -> QueryResult<impl Stream<Item = Result<TransactionHash, Status>>>

Get the list of transactions hashes for transactions that claim to be from the given account, but which are not yet finalized. They are either committed to a block or still pending. The stream will end when all the non-finalized transaction hashes have been returned. If the account does not exist an empty list will be returned.

This endpoint is not expected to return a large amount of data in most cases, but in bad network condtions it might.

Source

pub async fn get_block_items( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<BlockItem<EncodedPayload>, Status>>>>

Get the block items included in a given block. If the block does not exist QueryError::NotFound is returned. The stream will end when all the block items in the given block have been returned.

Source

pub async fn get_finalized_block_item( &mut self, th: TransactionHash, ) -> QueryResult<(BlockItem<EncodedPayload>, BlockHash, BlockItemSummary)>

Get the specific block item if it is finalized. If the transaction does not exist in a finalized block QueryError::NotFound is returned.

Note that this is not an efficient method since the node API does not allow for retrieving just the specific block item, but rather requires retrieving the full block. Use it for testing and debugging only.

The return value is a triple of the BlockItem, the hash of the block in which it is finalized, and the outcome in the form of BlockItemSummary.

Source

pub async fn shutdown(&mut self) -> RPCResult<()>

Shut down the node. Return a GRPC error if the shutdown failed.

Source

pub async fn peer_connect(&mut self, addr: SocketAddr) -> RPCResult<()>

Suggest a peer to connect to the submitted peer details. This, if successful, adds the peer to the list of given addresses. Otherwise return a GRPC error.

Note: The peer might not be connected to instantly, in that case the node will try to establish the connection in near future. This function returns a GRPC status ‘Ok’ in this case.

Source

pub async fn peer_disconnect(&mut self, addr: SocketAddr) -> RPCResult<()>

Disconnect from the peer and remove them from the given addresses list if they are on it. Return if the request was processed successfully. Otherwise return a GRPC error.

Source

pub async fn get_banned_peers(&mut self) -> RPCResult<Vec<BannedPeer>>

Get a vector of the banned peers.

Source

pub async fn ban_peer(&mut self, peer_to_ban: PeerToBan) -> RPCResult<()>

Ban a peer. When successful return Ok(()), and otherwise return an error describing the issue.

Source

pub async fn unban_peer(&mut self, banned_peer: &BannedPeer) -> RPCResult<()>

Unban a peer. When successful return Ok(()), and otherwise return an error describing the issue.

Source

pub async fn dump_start(&mut self, file: &Path, raw: bool) -> RPCResult<()>

Start a network dump if the feature is enabled on the node. This writes all the network packets into the given file. Return Ok(()) if a network dump has been initiated, and an error otherwise.

  • file - The file to write to.
  • raw - Whether raw packets should be included in the dump or not.

Note. If the feature ‘network_dump’ is not enabled on the node then this will return a ‘Precondition failed’ error.

Source

pub async fn dump_stop(&mut self) -> RPCResult<()>

Stop an ongoing network dump. Return nothing if it was successfully stopped, and otherwise return an error.

Note. If the feature ‘network_dump’ is not enabled on the node then this will return a ‘Precondition failed’ error.

Source

pub async fn get_peers_info(&mut self) -> RPCResult<PeersInfo>

Get a list of the peers that the node is connected to and associated network related information for each peer.

Source

pub async fn get_node_info(&mut self) -> RPCResult<NodeInfo>

Retrieve information about the node. The response contains meta information about the node such as the version of the software, the local time of the node etc.

The response also yields network related information such as the node ID, bytes sent/received etc.

Finally depending on the type of the node (regular node or ‘bootstrapper’) the response also yields baking information if the node is configured with baker credentials.

Bootstrappers do no reveal any consensus information as they do not run the consensus protocol.

Source

pub async fn get_baker_earliest_win_time( &mut self, bid: BakerId, ) -> RPCResult<DateTime<Utc>>

Get the projected earliest time a baker wins the opportunity to bake a block. If the baker is not a baker for the current reward period then then the timestamp returned is the projected time of the first block of the new reward period. Note that the endpoint is only available on a node running at least protocol version 6.

Source

pub async fn get_block_transaction_events( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<BlockItemSummary, Status>>>>

Get the transaction events in a given block. If the block does not exist QueryError::NotFound is returned. The stream will end when all the transaction events for a given block have been returned.

Source

pub async fn get_block_special_events( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<SpecialTransactionOutcome, Status>>>>

Get a the special events in a given block. If the block does not exist QueryError::NotFound is returned. The stream will end when all the special events for a given block have been returned.

These are events generated by the protocol, such as minting and reward payouts. They are not directly generated by any transaction.

Source

pub async fn get_block_pending_updates( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<PendingUpdate, Status>>>>

Get the pending updates to chain parameters at the end of a given block. If the block does not exist QueryError::NotFound is returned. The stream will end when all the pending updates for a given block have been returned.

Source

pub async fn get_winning_bakers_epoch( &mut self, ei: impl Into<EpochIdentifier>, ) -> QueryResult<impl Stream<Item = Result<WinningBaker, Status>>>

Get the winning bakers of an historical Epoch. Hence, when this function is invoked using EpochIdentifier::Block and the BlockIdentifier is either BlockIdentifier::Best or BlockIdentifier::LastFinal, then tonic::Code::Unavailable is returned, as these identifiers are not historical by definition.

The stream ends when there are no more rounds for the epoch specified. This only works for epochs in at least protocol version 6. Note that the endpoint is only available on a node running at least protocol version 6.

Source

pub async fn get_first_block_epoch( &mut self, ei: impl Into<EpochIdentifier>, ) -> QueryResult<BlockHash>

Get the first block of the epoch.

Source

pub async fn get_consensus_detailed_status( &mut self, genesis_index: Option<GenesisIndex>, ) -> RPCResult<ConsensusDetailedStatus>

Get the detailed status of the consensus. This is only available for consensus version 1. If the genesis index is not specified, the status for the current genesis index is returned.

Source

pub async fn get_next_update_sequence_numbers( &mut self, block_id: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<NextUpdateSequenceNumbers>>

Get next available sequence numbers for updating chain parameters after a given block. If the block does not exist then QueryError::NotFound is returned.

Source

pub async fn get_scheduled_release_accounts( &mut self, block_id: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<AccountPending, Status>>>>

Get all accounts that have scheduled releases, with the timestamp of the first pending scheduled release for that account. (Note, this only identifies accounts by index, and only indicates the first pending release for each account.)

Source

pub async fn get_cooldown_accounts( &mut self, block_id: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<AccountPending, Status>>>>

Get all accounts that have stake in cooldown, with the timestamp of the first pending cooldown expiry for each account. (Note, this only identifies accounts by index, and only indicates the first pending cooldown for each account.) Prior to protocol version 7, the resulting stream will always be empty.

Source

pub async fn get_pre_cooldown_accounts( &mut self, block_id: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<AccountIndex, Status>>>>

Get all accounts that have stake in pre-cooldown. (This only identifies accounts by index.) Prior to protocol version 7, the resulting stream will always be empty.

Source

pub async fn get_pre_pre_cooldown_accounts( &mut self, block_id: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<AccountIndex, Status>>>>

Get all accounts that have stake in pre-pre-cooldown. (This only identifies accounts by index.) Prior to protocol version 7, the resulting stream will always be empty.

Source

pub async fn get_block_chain_parameters( &mut self, block_id: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<ChainParameters>>

Get the chain parameters in effect after a given block. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn get_block_certificates( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<BlockCertificates>>

For a non-genesis block, this returns the QuorumCertificate, a TimeoutCertificate (if present) and EpochFinalizationEntry (if present). If the block being pointed to is not from protocol version 6 or above, then InvalidArgument is returned.

Source

pub async fn get_block_finalization_summary( &mut self, block_id: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<Option<FinalizationSummary>>>

Get the information about a finalization record in a block. A block can contain zero or one finalization record. If a record is contained then this query will return information about the finalization session that produced it, including the finalizers eligible for the session, their power, and whether they signed this particular record. If the block does not exist QueryError::NotFound is returned.

Source

pub async fn get_finalized_blocks_from( &mut self, start_height: AbsoluteBlockHeight, ) -> QueryResult<FinalizedBlocksStream>

Get a continous stream of finalized blocks starting from a given height. This function starts a background task (a tokio task) that listens for new finalized blocks. This task is killed when the FinalizedBlocksStream is dropped.

Source

pub async fn find_account_creation( &mut self, range: impl RangeBounds<AbsoluteBlockHeight>, addr: AccountAddress, ) -> QueryResult<(AbsoluteBlockHeight, BlockHash, AccountInfo)>

Find a block in which the account was created, if it exists and is finalized. The return value is a triple of the absolute block height and the corresponding block hash, and the account information at the end of that block. The block is the first block in which the account appears.

Note that this is not necessarily the initial state of the account since there can be transactions updating it in the same block that it is created.

Optional bounds can be provided, and the search will only consider blocks in that range. If the lower bound is not provided it defaults to 0, if the upper bound is not provided it defaults to the last finalized block at the time of the call.

If the account cannot be found QueryError::NotFound is returned.

Source

pub async fn find_instance_creation( &mut self, range: impl RangeBounds<AbsoluteBlockHeight>, addr: ContractAddress, ) -> QueryResult<(AbsoluteBlockHeight, BlockHash, InstanceInfo)>

Find a block in which the instance was created, if it exists and is finalized. The return value is a triple of the absolute block height and the corresponding block hash, and the instance information at the end of that block. The block is the first block in which the instance appears.

Note that this is not necessarily the initial state of the instance since there can be transactions updating the instance in the same block as the initialization transaction.

Optional bounds can be provided, and the search will only consider blocks in that range. If the lower bound is not provided it defaults to 0, if the upper bound is not provided it defaults to the last finalized block at the time of the call.

If the instance cannot be found QueryError::NotFound is returned.

Source

pub async fn find_first_finalized_block_no_earlier_than( &mut self, range: impl RangeBounds<AbsoluteBlockHeight>, time: DateTime<Utc>, ) -> QueryResult<BlockInfo>

Find the first (i.e., earliest) finalized block whose slot time is no earlier than the specified time. If a block is not found return QueryError::NotFound.

The search is limited to the bounds specified. If the lower bound is not provided it defaults to 0, if the upper bound is not provided it defaults to the last finalized block at the time of the call.

Source

pub async fn find_at_lowest_height<A, F: Future<Output = QueryResult<Option<A>>>>( &mut self, range: impl RangeBounds<AbsoluteBlockHeight>, test: impl Fn(Self, AbsoluteBlockHeight) -> F, ) -> QueryResult<A>

Find a finalized block with lowest height that satisfies the given condition. If a block is not found return QueryError::NotFound.

The test method should return Some if the object is found in the block, and None otherwise. It can also signal errors which will terminate search immediately.

The precondition for this method is that the test method is monotone, i.e., if block at height h satisfies the test then also a block at height h+1 does. If this precondition does not hold then the return value from this method is unspecified.

The search is limited to at most the given range, the upper bound is always at most the last finalized block at the time of the call. If the lower bound is not provided it defaults to 0, if the upper bound is not provided it defaults to the last finalized block at the time of the call.

Source

pub async fn find_earliest_finalized<A, F: Future<Output = QueryResult<Option<A>>>>( &mut self, range: impl RangeBounds<AbsoluteBlockHeight>, test: impl Fn(Self, AbsoluteBlockHeight, BlockHash) -> F, ) -> QueryResult<A>

👎Deprecated: Use find_at_lowest_height instead since it avoids an extra call.
Source

pub async fn get_bakers_reward_period( &mut self, bi: impl IntoBlockIdentifier, ) -> QueryResult<QueryResponse<impl Stream<Item = Result<BakerRewardPeriodInfo, Status>>>>

Get all bakers in the reward period of a block. This endpoint is only supported for protocol version 4 and onwards. If the protocol does not support the endpoint then an IllegalArgument is returned.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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