Add last valid block height to rpc Fees (#17506)

* Add last_valid_block_height to fees rpc

* Add getBlockHeight rpc

* Update docs
This commit is contained in:
Tyera Eulberg
2021-05-26 01:26:19 -06:00
committed by GitHub
parent 7ce910f459
commit e9bc1c6b07
7 changed files with 106 additions and 3 deletions

View File

@@ -426,6 +426,20 @@ impl RpcClient {
)
}
pub fn get_block_height(&self) -> ClientResult<u64> {
self.get_block_height_with_commitment(self.commitment_config)
}
pub fn get_block_height_with_commitment(
&self,
commitment_config: CommitmentConfig,
) -> ClientResult<u64> {
self.send(
RpcRequest::GetBlockHeight,
json!([self.maybe_map_commitment(commitment_config)?]),
)
}
pub fn get_slot_leaders(&self, start_slot: Slot, limit: u64) -> ClientResult<Vec<Pubkey>> {
self.send(RpcRequest::GetSlotLeaders, json!([start_slot, limit]))
.and_then(|slot_leaders: Vec<String>| {
@@ -1230,6 +1244,7 @@ impl RpcClient {
blockhash,
fee_calculator,
last_valid_slot,
..
},
}) = self
.send::<Response<RpcFees>>(
@@ -1237,6 +1252,19 @@ impl RpcClient {
json!([self.maybe_map_commitment(commitment_config)?]),
) {
(context, blockhash, fee_calculator, last_valid_slot)
} else if let Ok(Response {
context,
value:
DeprecatedRpcFees {
blockhash,
fee_calculator,
last_valid_slot,
},
}) = self.send::<Response<DeprecatedRpcFees>>(
RpcRequest::GetFees,
json!([self.maybe_map_commitment(commitment_config)?]),
) {
(context, blockhash, fee_calculator, last_valid_slot)
} else if let Ok(Response {
context,
value: