Add RpcClient::get_stake_activation()

This commit is contained in:
Michael Vines 2021-03-26 18:11:11 -07:00
parent 60b4771fc6
commit 5791b95b17
2 changed files with 21 additions and 2 deletions

View File

@ -7,7 +7,7 @@ use crate::{
RpcConfirmedBlockConfig, RpcConfirmedTransactionConfig,
RpcGetConfirmedSignaturesForAddress2Config, RpcLargestAccountsConfig,
RpcProgramAccountsConfig, RpcSendTransactionConfig, RpcSimulateTransactionConfig,
RpcTokenAccountsFilter,
RpcStakeConfig, RpcTokenAccountsFilter,
},
rpc_request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter},
rpc_response::*,
@ -23,7 +23,7 @@ use solana_account_decoder::{
};
use solana_sdk::{
account::Account,
clock::{Slot, UnixTimestamp, DEFAULT_MS_PER_SLOT, MAX_HASH_AGE_IN_SECONDS},
clock::{Epoch, Slot, UnixTimestamp, DEFAULT_MS_PER_SLOT, MAX_HASH_AGE_IN_SECONDS},
commitment_config::{CommitmentConfig, CommitmentLevel},
epoch_info::EpochInfo,
epoch_schedule::EpochSchedule,
@ -425,6 +425,23 @@ impl RpcClient {
})
}
pub fn get_stake_activation(
&self,
stake_account: Pubkey,
epoch: Option<Epoch>,
) -> ClientResult<RpcStakeActivation> {
self.send(
RpcRequest::GetStakeActivation,
json!([
stake_account.to_string(),
RpcStakeConfig {
epoch,
commitment: Some(self.commitment_config),
}
]),
)
}
pub fn supply(&self) -> RpcResult<RpcSupply> {
self.supply_with_commitment(self.commitment_config)
}

View File

@ -43,6 +43,7 @@ pub enum RpcRequest {
GetStorageTurn,
GetStorageTurnRate,
GetSlotsPerSegment,
GetStakeActivation,
GetStoragePubkeysForSlot,
GetSupply,
GetTokenAccountBalance,
@ -98,6 +99,7 @@ impl fmt::Display for RpcRequest {
RpcRequest::GetSlot => "getSlot",
RpcRequest::GetSlotLeader => "getSlotLeader",
RpcRequest::GetSlotLeaders => "getSlotLeaders",
RpcRequest::GetStakeActivation => "getStakeActivation",
RpcRequest::GetStorageTurn => "getStorageTurn",
RpcRequest::GetStorageTurnRate => "getStorageTurnRate",
RpcRequest::GetSlotsPerSegment => "getSlotsPerSegment",