getLeaderSchedule now supports filtered results based on validator identity

This commit is contained in:
Michael Vines
2021-04-21 14:13:41 -07:00
parent 3f92abedd5
commit 6004c0abf5
6 changed files with 120 additions and 24 deletions

View File

@@ -9,11 +9,7 @@ use {
http_sender::HttpSender,
mock_sender::{MockSender, Mocks},
rpc_config::RpcAccountInfoConfig,
rpc_config::{
RpcBlockConfig, RpcEpochConfig, RpcLargestAccountsConfig, RpcProgramAccountsConfig,
RpcRequestAirdropConfig, RpcSendTransactionConfig, RpcSignaturesForAddressConfig,
RpcSimulateTransactionConfig, RpcTokenAccountsFilter, RpcTransactionConfig,
},
rpc_config::*,
rpc_request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter},
rpc_response::*,
rpc_sender::RpcSender,
@@ -880,7 +876,7 @@ impl RpcClient {
&self,
slot: Option<Slot>,
) -> ClientResult<Option<RpcLeaderSchedule>> {
self.get_leader_schedule_with_commitment(slot, self.commitment_config)
self.get_leader_schedule_with_config(slot, RpcLeaderScheduleConfig::default())
}
pub fn get_leader_schedule_with_commitment(
@@ -890,10 +886,24 @@ impl RpcClient {
) -> ClientResult<Option<RpcLeaderSchedule>> {
self.send(
RpcRequest::GetLeaderSchedule,
json!([slot, self.maybe_map_commitment(commitment_config)?]),
json!([
slot,
RpcLeaderScheduleConfig {
commitment: Some(self.maybe_map_commitment(commitment_config)?),
..RpcLeaderScheduleConfig::default()
}
]),
)
}
pub fn get_leader_schedule_with_config(
&self,
slot: Option<Slot>,
config: RpcLeaderScheduleConfig,
) -> ClientResult<Option<RpcLeaderSchedule>> {
self.send(RpcRequest::GetLeaderSchedule, json!([slot, config]))
}
pub fn get_epoch_schedule(&self) -> ClientResult<EpochSchedule> {
self.send(RpcRequest::GetEpochSchedule, Value::Null)
}

View File

@@ -41,6 +41,14 @@ pub struct RpcRequestAirdropConfig {
pub commitment: Option<CommitmentConfig>,
}
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RpcLeaderScheduleConfig {
pub identity: Option<String>, // validator identity, as a base-58 encoded string
#[serde(flatten)]
pub commitment: Option<CommitmentConfig>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum RpcLargestAccountsFilter {

View File

@@ -254,10 +254,10 @@ pub struct RpcVoteAccountStatus {
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct RpcVoteAccountInfo {
/// Vote account pubkey as base-58 encoded string
/// Vote account address, as base-58 encoded string
pub vote_pubkey: String,
/// The pubkey of the node that votes using this account
/// The validator identity, as base-58 encoded string
pub node_pubkey: String,
/// The current stake, in lamports, delegated to this vote account