Skip to content

Commit

Permalink
use jsonrpsee in zebra-node-services
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed Nov 27, 2024
1 parent ac4ff2e commit 5f64fb3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
17 changes: 1 addition & 16 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2297,21 +2297,6 @@ dependencies = [
"serde_json",
]

[[package]]
name = "jsonrpc-core"
version = "18.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb"
dependencies = [
"futures",
"futures-executor",
"futures-util",
"log",
"serde",
"serde_derive",
"serde_json",
]

[[package]]
name = "jsonrpsee"
version = "0.24.7"
Expand Down Expand Up @@ -6188,7 +6173,7 @@ name = "zebra-node-services"
version = "1.0.0-beta.42"
dependencies = [
"color-eyre",
"jsonrpc-core",
"jsonrpsee-types",
"reqwest 0.11.27",
"serde",
"serde_json",
Expand Down
6 changes: 3 additions & 3 deletions zebra-node-services/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ getblocktemplate-rpcs = [

rpc-client = [
"color-eyre",
"jsonrpc-core",
"jsonrpsee-types",
"reqwest",
"serde",
"serde_json",
Expand All @@ -43,7 +43,8 @@ zebra-chain = { path = "../zebra-chain" , version = "1.0.0-beta.42" }

# Tool and test feature rpc-client
color-eyre = { version = "0.6.3", optional = true }
jsonrpc-core = { version = "18.0.0", optional = true }
jsonrpsee-types = { version = "0.24.7", optional = true }

# Security: avoid default dependency on openssl
reqwest = { version = "0.11.26", default-features = false, features = ["rustls-tls"], optional = true }
serde = { version = "1.0.211", optional = true }
Expand All @@ -53,7 +54,6 @@ tokio = { version = "1.41.0", features = ["time", "sync"] }
[dev-dependencies]

color-eyre = "0.6.3"
jsonrpc-core = "18.0.0"
reqwest = { version = "0.11.26", default-features = false, features = ["rustls-tls"] }
serde = "1.0.211"
serde_json = "1.0.132"
10 changes: 4 additions & 6 deletions zebra-node-services/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ impl RpcRequestClient {
fn json_result_from_response_text<T: serde::de::DeserializeOwned>(
response_text: &str,
) -> std::result::Result<T, BoxError> {
use jsonrpc_core::Output;

let output: Output = serde_json::from_str(response_text)?;
match output {
Output::Success(success) => Ok(serde_json::from_value(success.result)?),
Output::Failure(failure) => Err(failure.error.into()),
let output: jsonrpsee_types::Response<serde_json::Value> = serde_json::from_str(response_text)?;
match output.payload {
jsonrpsee_types::ResponsePayload::Success(success) => Ok(serde_json::from_value(success.into_owned())?),
jsonrpsee_types::ResponsePayload::Error(failure) => Err(failure.to_string().into()),
}
}
}

0 comments on commit 5f64fb3

Please sign in to comment.