pub struct BankDataClient { /* private fields */ }Expand description
The Client.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(sender: RpcChannel) -> Self
pub fn new(sender: RpcChannel) -> Self
Creates a new Client.
Sourcepub fn get_minimum_balance_for_rent_exemption(
&self,
data_len: usize,
commitment: Option<CommitmentConfig>,
) -> impl Future<Output = RpcResult<u64>>
pub fn get_minimum_balance_for_rent_exemption( &self, data_len: usize, commitment: Option<CommitmentConfig>, ) -> impl Future<Output = RpcResult<u64>>
Returns the minimum balance required for rent exemption based on the given data length.
This RPC method calculates the minimum balance required for an account to be exempt from rent charges. It uses the data length of the account to determine the balance. The result can help users manage their accounts by ensuring they have enough balance to cover rent exemption, preventing accounts from being purged by the system.
§Parameters
data_len: The length (in bytes) of the account data. This is used to determine the minimum balance required for rent exemption.commitment: (Optional) ACommitmentConfigthat allows specifying the level of commitment for querying. If not provided, the default commitment level will be used.
§Returns
Result<u64>: The method returns the minimum balance required for rent exemption as au64. If successful, it will be wrapped inOk, otherwise an error will be returned.
§Example Request (JSON-RPC)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getMinimumBalanceForRentExemption",
"params": [128]
}§Example Response
{
"jsonrpc": "2.0",
"result": 2039280,
"id": 1
}§Notes
- This method is commonly used to determine the required balance when creating new accounts or performing account setup operations that need rent exemption.
- The
commitmentparameter allows users to specify the level of assurance they want regarding the state of the ledger. For example, usingConfirmedorFinalizedensures that the state is more reliable.
§Errors
- If there is an issue with the
data_lenorcommitmentparameter (e.g., invalid data), an error will be returned.
Sourcepub fn get_inflation_governor(
&self,
commitment: Option<CommitmentConfig>,
) -> impl Future<Output = RpcResult<RpcInflationGovernor>>
pub fn get_inflation_governor( &self, commitment: Option<CommitmentConfig>, ) -> impl Future<Output = RpcResult<RpcInflationGovernor>>
Retrieves the inflation governor settings for the network.
This RPC method returns the current inflation governor configuration, which controls the inflation rate of the network. The inflation governor is responsible for adjusting the inflation rate over time, with parameters like the initial and terminal inflation rates, the taper rate, the foundation amount, and the foundation term.
§Parameters
commitment: (Optional) ACommitmentConfigthat specifies the commitment level for querying the inflation governor settings. If not provided, the default commitment level is used. Valid commitment levels includeProcessed,Confirmed, orFinalized.
§Returns
Result<RpcInflationGovernor>: The method returns anRpcInflationGovernorstruct that contains the inflation parameters if successful. Otherwise, an error will be returned.
§Example Request (JSON-RPC)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getInflationGovernor",
"params": []
}§Example Response
{
"jsonrpc": "2.0",
"result": {
"initial": 0.15,
"terminal": 0.05,
"taper": 0.9,
"foundation": 0.02,
"foundation_term": 5.0
},
"id": 1
}§Notes
- The inflation governor defines how inflation changes over time, ensuring the network’s growth remains stable and sustainable.
- The
commitmentparameter allows users to define how strongly they want to ensure the inflation data is confirmed or finalized when queried. For example, usingConfirmedorFinalizedensures a more reliable inflation state.
§Errors
- If there is an issue with the
commitmentparameter or an internal error occurs, an error will be returned.
Sourcepub fn get_inflation_rate(
&self,
) -> impl Future<Output = RpcResult<RpcInflationRate>>
pub fn get_inflation_rate( &self, ) -> impl Future<Output = RpcResult<RpcInflationRate>>
Retrieves the current inflation rate for the network.
This RPC method returns the current inflation rate, including the breakdown of inflation allocated to different entities such as validators and the foundation, along with the current epoch during which the rate applies.
§Parameters
- No parameters are required for this method.
§Returns
Result<RpcInflationRate>: The method returns anRpcInflationRatestruct that contains the total inflation rate, the validator portion, the foundation portion, and the epoch during which this inflation rate applies.
§Example Request (JSON-RPC)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getInflationRate",
"params": []
}§Example Response
{
"jsonrpc": "2.0",
"result": {
"total": 0.10,
"validator": 0.07,
"foundation": 0.03,
"epoch": 1500
},
"id": 1
}§Notes
- The total inflation rate is distributed among validators and the foundation based on the configuration defined in the inflation governor.
- The epoch field indicates the current epoch number during which this inflation rate applies. An epoch is a period during which the network operates under certain parameters.
- Inflation rates can change over time depending on network conditions and governance decisions.
§Errors
- If there is an internal error, or if the RPC request is malformed, an error will be returned.
Sourcepub fn get_epoch_schedule(
&self,
) -> impl Future<Output = RpcResult<EpochSchedule>>
pub fn get_epoch_schedule( &self, ) -> impl Future<Output = RpcResult<EpochSchedule>>
Retrieves the epoch schedule for the network.
This RPC method returns the configuration for the network’s epoch schedule, including details on the number of slots per epoch, leader schedule offsets, and epoch warmup.
§Parameters
- No parameters are required for this method.
§Returns
Result<EpochSchedule>: The method returns anEpochSchedulestruct, which contains information about the slots per epoch, leader schedule offsets, warmup state, and the first epoch after the warmup period.
§Example Request (JSON-RPC)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getEpochSchedule",
"params": []
}§Example Response
{
"jsonrpc": "2.0",
"result": {
"slotsPerEpoch": 432000,
"leaderScheduleSlotOffset": 500,
"warmup": true,
"firstNormalEpoch": 8,
"firstNormalSlot": 1073741824
},
"id": 1
}§Notes
- The
slots_per_epochdefines the maximum number of slots in each epoch, which determines the number of time slots available for network validators to produce blocks. - The
leader_schedule_slot_offsetspecifies how many slots before an epoch’s start the leader schedule calculation begins for that epoch. - The
warmupfield indicates whether the epochs start short and grow over time. - The
first_normal_epochmarks the first epoch after the warmup period. - The
first_normal_slotgives the first slot after the warmup period in terms of the number of slots from the start of the network.
§Errors
- If the RPC request is malformed, or if there is an internal error, an error will be returned.
Sourcepub fn get_slot_leader(
&self,
config: Option<RpcContextConfig>,
) -> impl Future<Output = RpcResult<String>>
pub fn get_slot_leader( &self, config: Option<RpcContextConfig>, ) -> impl Future<Output = RpcResult<String>>
Retrieves the leader of the current slot.
This RPC method returns the leader for the current slot in the Solana network. The leader is responsible for producing blocks for the current slot. The leader is selected based on the Solana consensus mechanism.
§Parameters
config: An optional configuration for the request, which can include:commitment: A commitment level that defines how “final” the data must be.min_context_slot: An optional parameter to specify a minimum slot for the request.
§Returns
Result<String>: The method returns aStringrepresenting the public key of the leader for the current slot.
§Example Request (JSON-RPC)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getSlotLeader",
"params": []
}§Example Response
{
"jsonrpc": "2.0",
"result": "3HgA9r8H9z5Pb2L6Pt5Yq1QoFwgr6YwdKKUh9n2ANp5U"
}§Notes
- The leader for a given slot is selected based on the Solana network’s consensus mechanism, and this method allows you to query the current leader.
Sourcepub fn get_slot_leaders(
&self,
start_slot: Slot,
limit: u64,
) -> impl Future<Output = RpcResult<Vec<String>>>
pub fn get_slot_leaders( &self, start_slot: Slot, limit: u64, ) -> impl Future<Output = RpcResult<Vec<String>>>
Retrieves the leaders for a specified range of slots.
This RPC method returns the leaders for a specified range of slots in the Solana network. You can
specify the start_slot from which the leaders should be queried and limit the number of results
with the limit parameter. The leaders are responsible for producing blocks in the respective slots.
§Parameters
start_slot: The starting slot number for which the leaders should be queried.limit: The number of slots (starting fromstart_slot) for which the leaders should be retrieved.
§Returns
Result<Vec<String>>: A vector ofStringvalues representing the public keys of the leaders for the specified slot range.
§Example Request (JSON-RPC)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getSlotLeaders",
"params": [1000, 5]
}§Example Response
{
"jsonrpc": "2.0",
"result": [
"3HgA9r8H9z5Pb2L6Pt5Yq1QoFwgr6YwdKKUh9n2ANp5U",
"BBh1FwXts8EZY6rPZ5kS2ygq99wYjFd5K5daRjc7eF9X",
"4XYo7yP5J2J8sLNSW3wGYPk3mdS1rbZUy4oFCp7wH1DN",
"8v1Cp6sHZh8XfGWS7sHZczH3v9NxdgMbo3g91Sh88dcJ",
"N6bPqwEoD9StS4AnzE27rHyz47tPcsZQjvW9w8p2NhF7"
]
}§Notes
- The leaders are returned in the order corresponding to the slots queried, starting from
start_slotand continuing forlimitslots. - This method provides an efficient way to get multiple leaders for a range of slots, useful for tracking leaders over time or for scheduling purposes in decentralized applications.
Sourcepub fn get_block_production(
&self,
config: Option<RpcBlockProductionConfig>,
) -> impl Future<Output = RpcResult<RpcResponse<RpcBlockProduction>>>
pub fn get_block_production( &self, config: Option<RpcBlockProductionConfig>, ) -> impl Future<Output = RpcResult<RpcResponse<RpcBlockProduction>>>
Retrieves block production information for the specified validator identity or range of slots.
This RPC method returns block production details for a given validator identity or a range of slots
within a certain epoch. If no identity is provided, the method returns block production data for all
validators. If a range is provided, it will return block production information for the slots within
the specified range.
§Parameters
config: An optional configuration object that can include:identity: The base-58 encoded public key of a validator to query for block production data. IfNone, results for all validators will be returned.range: A range of slots for which block production information is needed. The range will default to the current epoch ifNone.commitment: The commitment level (optional) to use when querying for the block production data.
§Returns
Result<RpcResponse<RpcBlockProduction>>: The result contains a response object with block production data, including the number of leader slots and blocks produced by each validator.
§Example Request (JSON-RPC)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockProduction",
"params": [{
"identity": "3HgA9r8H9z5Pb2L6Pt5Yq1QoFwgr6YwdKKUh9n2ANp5U",
"range": {
"firstSlot": 1000,
"lastSlot": 1050
}
}]
}§Example Response
{
"jsonrpc": "2.0",
"result": {
"byIdentity": {
"3HgA9r8H9z5Pb2L6Pt5Yq1QoFwgr6YwdKKUh9n2ANp5U": [10, 8],
"BBh1FwXts8EZY6rPZ5kS2ygq99wYjFd5K5daRjc7eF9X": [5, 4]
},
"range": {
"firstSlot": 1000,
"lastSlot": 1050
}
}
}§Notes
- The response contains a map of validator identities to a tuple of two values:
- The first value is the number of leader slots.
- The second value is the number of blocks produced by that validator in the queried range.
- The
rangeobject specifies the range of slots that the block production information applies to, withfirst_slotbeing the starting slot andlast_slotbeing the optional ending slot.
§Example Response Interpretation
- In the example response, the identity
3HgA9r8H9z5Pb2L6Pt5Yq1QoFwgr6YwdKKUh9n2ANp5Uproduced 10 leader slots and 8 blocks between slots 1000 and 1050. - Similarly,
BBh1FwXts8EZY6rPZ5kS2ygq99wYjFd5K5daRjc7eF9Xproduced 5 leader slots and 4 blocks in the same slot range.
Trait Implementations§
Source§impl From<RpcChannel> for Client
impl From<RpcChannel> for Client
Source§fn from(channel: RpcChannel) -> Self
fn from(channel: RpcChannel) -> Self
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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