Skip to content

Commit

Permalink
Merge #324: Use serde_json::value::to_raw_value in Client::call()
Browse files Browse the repository at this point in the history
308448d Use 'serde_json::value::to_raw_value' (Roman Zeyde)

Pull request description:

  Since MSRV is 1.56.1: https://github.com/rust-bitcoin/rust-bitcoincore-rpc#minimum-supported-rust-version-msrv

ACKs for top commit:
  tcharding:
    ACK 308448d

Tree-SHA512: 2a3aec5d1407b2757d18fa10520ff2fe2a52d1eebd6a6f04e49a1a0cc1d6cfb82f3a3f8ae65ef862f703b23cd0613c0d467387c18cfeaf61e01112a2e71d497b
  • Loading branch information
apoelstra committed May 6, 2024
2 parents ce665f1 + 308448d commit 4653d23
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,10 +1314,7 @@ impl RpcApi for Client {
) -> Result<T> {
let raw_args: Vec<_> = args
.iter()
.map(|a| {
let json_string = serde_json::to_string(a)?;
serde_json::value::RawValue::from_string(json_string) // we can't use to_raw_value here due to compat with Rust 1.29
})
.map(serde_json::value::to_raw_value)
.map(|a| a.map_err(|e| Error::Json(e)))
.collect::<Result<Vec<_>>>()?;
let req = self.client.build_request(&cmd, &raw_args);
Expand Down Expand Up @@ -1345,11 +1342,7 @@ fn log_response(cmd: &str, resp: &Result<jsonrpc::Response>) {
debug!(target: "bitcoincore_rpc", "JSON-RPC error for {}: {:?}", cmd, e);
}
} else if log_enabled!(Trace) {
// we can't use to_raw_value here due to compat with Rust 1.29
let def = serde_json::value::RawValue::from_string(
serde_json::Value::Null.to_string(),
)
.unwrap();
let def = serde_json::value::to_raw_value(&serde_json::value::Value::Null).unwrap();
let result = resp.result.as_ref().unwrap_or(&def);
trace!(target: "bitcoincore_rpc", "JSON-RPC response for {}: {}", cmd, result);
}
Expand Down

0 comments on commit 4653d23

Please sign in to comment.