-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use serde_json::value::to_raw_value
in Client::call()
#324
Conversation
serde_json::value::to_raw_value
in Client::call()
For context: this comment appears in #180 and the MSRV incompatibility seems to come from us pinning a version of serde_json somewhere in our dep tree. This function seems to be introduced in As a second thought, in rust-jsonrpc we have some hacky stuff related to raw values and maybe we should be using this new method as well. |
IIRC, it shouldn't change the functionality - only simplify the existing code a bit. I have thought to suggest this change when reviewing the code at: rust-bitcoincore-rpc/client/src/client.rs Line 1319 in 33293a5
If it's not relevant, I can close this PR. |
Ah yeah, I've spent more time in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 8049ea6
I took the liberty of editing the PR description for you @romanz because the MSRV has bumped since this PR was opened. The commit message doesn't include the msrv so we are good to go. Thanks man! |
LGTM, thanks @tcharding! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 8049ea6
I just noticed that there is another instance of this in diff --git a/client/src/client.rs b/client/src/client.rs
index 745b863..80fd717 100644
--- a/client/src/client.rs
+++ b/client/src/client.rs
@@ -1342,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);
let result = resp.result.as_ref().unwrap_or(&def);
trace!(target: "bitcoincore_rpc", "JSON-RPC response for {}: {}", cmd, result); |
Good catch. And yep, I think your solution is right ... I don't see a way to directly create a raw null. |
Thanks - fixed in 308448d. |
CI fail is unrelated to this PR, fixed in #351 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 308448d
Since MSRV is 1.56.1: https://github.com/rust-bitcoin/rust-bitcoincore-rpc#minimum-supported-rust-version-msrv