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

@ -545,12 +545,16 @@ impl JsonRpcRequestProcessor {
let last_valid_slot = bank
.get_blockhash_last_valid_slot(&blockhash)
.expect("bank blockhash queue should contain blockhash");
let last_valid_block_height = bank
.get_blockhash_last_valid_block_height(&blockhash)
.expect("bank blockhash queue should contain blockhash");
new_response(
&bank,
RpcFees {
blockhash: blockhash.to_string(),
fee_calculator,
last_valid_slot,
last_valid_block_height,
},
)
}
@ -606,6 +610,10 @@ impl JsonRpcRequestProcessor {
self.bank(commitment).slot()
}
fn get_block_height(&self, commitment: Option<CommitmentConfig>) -> u64 {
self.bank(commitment).block_height()
}
fn get_max_retransmit_slot(&self) -> Slot {
self.max_slots.retransmit.load(Ordering::Relaxed)
}
@ -2094,6 +2102,13 @@ pub mod rpc_minimal {
commitment: Option<CommitmentConfig>,
) -> Result<Slot>;
#[rpc(meta, name = "getBlockHeight")]
fn get_block_height(
&self,
meta: Self::Metadata,
commitment: Option<CommitmentConfig>,
) -> Result<u64>;
#[rpc(meta, name = "getSnapshotSlot")]
fn get_snapshot_slot(&self, meta: Self::Metadata) -> Result<Slot>;
@ -2182,6 +2197,15 @@ pub mod rpc_minimal {
Ok(meta.get_slot(commitment))
}
fn get_block_height(
&self,
meta: Self::Metadata,
commitment: Option<CommitmentConfig>,
) -> Result<u64> {
debug!("get_block_height rpc request received");
Ok(meta.get_block_height(commitment))
}
fn get_snapshot_slot(&self, meta: Self::Metadata) -> Result<Slot> {
debug!("get_snapshot_slot rpc request received");
@ -5215,6 +5239,7 @@ pub mod tests {
"lamportsPerSignature": 0,
},
"lastValidSlot": MAX_RECENT_BLOCKHASHES,
"lastValidBlockHeight": MAX_RECENT_BLOCKHASHES,
}},
"id": 1
});