Update fee api to use blockhash (#21054)

This commit is contained in:
Jack May
2021-10-29 13:52:59 -07:00
committed by GitHub
parent aea3c66fa8
commit bced07a099
16 changed files with 142 additions and 93 deletions

View File

@ -4285,7 +4285,7 @@ impl RpcClient {
#[deprecated(
since = "1.9.0",
note = "Please use `get_new_latest_blockhash` instead"
note = "Please do not use, will no longer be available in the future"
)]
#[allow(deprecated)]
pub fn get_new_blockhash(&self, blockhash: &Hash) -> ClientResult<(Hash, FeeCalculator)> {
@ -4802,7 +4802,9 @@ impl RpcClient {
#[allow(deprecated)]
pub fn get_fee_for_message(&self, message: &Message) -> ClientResult<u64> {
if self.get_node_version()? < semver::Version::new(1, 9, 0) {
let Fees { fee_calculator, .. } = self.get_fees()?;
let fee_calculator = self
.get_fee_calculator_for_blockhash(&message.recent_blockhash)?
.ok_or_else(|| ClientErrorKind::Custom("Invalid blockhash".to_string()))?;
Ok(fee_calculator
.lamports_per_signature
.saturating_mul(message.header.num_required_signatures as u64))

View File

@ -605,12 +605,6 @@ impl SyncClient for ThinClient {
.get_fee_for_message(message)
.map_err(|e| e.into())
}
fn get_new_latest_blockhash(&self, blockhash: &Hash) -> TransportResult<Hash> {
self.rpc_client()
.get_new_latest_blockhash(blockhash)
.map_err(|e| e.into())
}
}
impl AsyncClient for ThinClient {