From 3f0995d3b4fb6c2c13eea8ab514dc1f76ff224f2 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 26 May 2020 17:23:58 -0600 Subject: [PATCH] Add commitment parameter to getFeeCalculatorForBlockhash (#10255) * Accept commitment parameter on getFeeCalculatorForBlockhash * Update docs * Add get_fee_calculator_for_blockhash_with_commitment to rpc client --- client/src/rpc_client.rs | 22 +++++++++++++++++++--- core/src/rpc.rs | 7 +++++-- docs/src/apps/jsonrpc-api.md | 3 ++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/client/src/rpc_client.rs b/client/src/rpc_client.rs index 3739d5682..65f287500 100644 --- a/client/src/rpc_client.rs +++ b/client/src/rpc_client.rs @@ -671,12 +671,28 @@ impl RpcClient { &self, blockhash: &Hash, ) -> ClientResult> { - let Response { value, .. } = self.send::>>( + Ok(self + .get_fee_calculator_for_blockhash_with_commitment( + blockhash, + CommitmentConfig::default(), + )? + .value) + } + + pub fn get_fee_calculator_for_blockhash_with_commitment( + &self, + blockhash: &Hash, + commitment_config: CommitmentConfig, + ) -> RpcResult> { + let Response { context, value } = self.send::>>( RpcRequest::GetFeeCalculatorForBlockhash, - json!([blockhash.to_string()]), + json!([blockhash.to_string(), commitment_config]), )?; - Ok(value.map(|rf| rf.fee_calculator)) + Ok(Response { + context, + value: value.map(|rf| rf.fee_calculator), + }) } pub fn get_fee_rate_governor(&self) -> RpcResult { diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 934b25d9c..4933354c4 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -226,8 +226,9 @@ impl JsonRpcRequestProcessor { fn get_fee_calculator_for_blockhash( &self, blockhash: &Hash, + commitment: Option, ) -> RpcResponse> { - let bank = &*self.bank(None)?; + let bank = &*self.bank(commitment)?; let fee_calculator = bank.get_fee_calculator(blockhash); new_response( bank, @@ -821,6 +822,7 @@ pub trait RpcSol { &self, meta: Self::Metadata, blockhash: String, + commitment: Option, ) -> RpcResponse>; #[rpc(meta, name = "getFeeRateGovernor")] @@ -1162,6 +1164,7 @@ impl RpcSol for RpcSolImpl { &self, meta: Self::Metadata, blockhash: String, + commitment: Option, ) -> RpcResponse> { debug!("get_fee_calculator_for_blockhash rpc request received"); let blockhash = @@ -1169,7 +1172,7 @@ impl RpcSol for RpcSolImpl { meta.request_processor .read() .unwrap() - .get_fee_calculator_for_blockhash(&blockhash) + .get_fee_calculator_for_blockhash(&blockhash, commitment) } fn get_fee_rate_governor(&self, meta: Self::Metadata) -> RpcResponse { diff --git a/docs/src/apps/jsonrpc-api.md b/docs/src/apps/jsonrpc-api.md index 67c5834b3..7b142690f 100644 --- a/docs/src/apps/jsonrpc-api.md +++ b/docs/src/apps/jsonrpc-api.md @@ -491,7 +491,8 @@ Returns the fee calculator associated with the query blockhash, or `null` if the #### Parameters: -* `blockhash: `, query blockhash as a Base58 encoded string +* `` - query blockhash as a Base58 encoded string +* `` - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) #### Results: