GetLeaderSchedule can now return a schedule for arbitrary epochs (#7545)

automerge
This commit is contained in:
mergify[bot]
2019-12-17 23:15:04 -08:00
committed by Grimes
parent c7669d4afe
commit 8a879a52ef
4 changed files with 97 additions and 5 deletions

View File

@ -248,6 +248,39 @@ impl RpcClient {
})
}
pub fn get_leader_schedule(&self, slot: Option<Slot>) -> io::Result<Option<Vec<String>>> {
self.get_leader_schedule_with_commitment(slot, CommitmentConfig::default())
}
pub fn get_leader_schedule_with_commitment(
&self,
slot: Option<Slot>,
commitment_config: CommitmentConfig,
) -> io::Result<Option<Vec<String>>> {
let params = slot.map(|slot| json!(slot));
let response = self
.client
.send(
&RpcRequest::GetLeaderSchedule,
params,
0,
commitment_config.ok(),
)
.map_err(|err| {
io::Error::new(
io::ErrorKind::Other,
format!("GetLeaderSchedule request failure: {:?}", err),
)
})?;
serde_json::from_value(response).map_err(|err| {
io::Error::new(
io::ErrorKind::Other,
format!("GetLeaderSchedule failure: {}", err),
)
})
}
pub fn get_epoch_schedule(&self) -> io::Result<EpochSchedule> {
let response = self
.client

View File

@ -121,6 +121,7 @@ pub enum RpcRequest {
GetEpochSchedule,
GetGenesisHash,
GetInflation,
GetLeaderSchedule,
GetNumBlocksSinceSignatureConfirmation,
GetProgramAccounts,
GetRecentBlockhash,
@ -161,6 +162,7 @@ impl RpcRequest {
RpcRequest::GetEpochSchedule => "getEpochSchedule",
RpcRequest::GetGenesisHash => "getGenesisHash",
RpcRequest::GetInflation => "getInflation",
RpcRequest::GetLeaderSchedule => "getLeaderSchedule",
RpcRequest::GetNumBlocksSinceSignatureConfirmation => {
"getNumBlocksSinceSignatureConfirmation"
}