Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 0a61c83

Browse files
committed
fix: rpc_query
1 parent 5ff0165 commit 0a61c83

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

client/service/src/lib.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ mod task_manager;
3737
use std::{collections::HashMap, net::SocketAddr, pin::Pin, task::Poll};
3838

3939
use codec::{Decode, Encode};
40-
use futures::{stream, FutureExt, Stream, StreamExt};
41-
use jsonrpsee::RpcModule;
40+
use futures::{channel::mpsc, stream, FutureExt, Stream, StreamExt};
41+
use jsonrpsee::{core::Error as JsonRpseeError, RpcModule};
4242
use log::{debug, error, warn};
4343
use sc_client_api::{blockchain::HeaderBackend, BlockchainEvents};
4444
use sc_network::PeerId;
4545
use sc_utils::mpsc::TracingUnboundedReceiver;
46-
use serde::Serialize;
4746
use sp_runtime::{
4847
generic::BlockId,
4948
traits::{Block as BlockT, Header as HeaderT},
@@ -87,19 +86,18 @@ pub struct RpcHandlers(Arc<RpcModule<()>>);
8786
impl RpcHandlers {
8887
/// Starts an RPC query.
8988
///
90-
/// The query is passed as a method name and params, the params must be serialized as array.
89+
/// The query is passed as a string and must be valid JSON-RPC request object.
9190
///
92-
/// Returns a `Future` that contains the optional response and a stream.
91+
/// Returns a response and a stream if the call successful, fails if the
92+
/// query could not be decoded as a JSON-RPC request object.
9393
///
9494
/// If the request subscribes you to events, the `stream` can be used to
9595
/// retrieve the events.
96-
pub async fn rpc_query<T: Serialize>(
96+
pub async fn rpc_query(
9797
&self,
98-
method: &str,
99-
params: Vec<T>,
100-
// ) -> Option<(String, mpsc::UnboundedReceiver<String>)> {
101-
) -> Option<jsonrpsee::core::server::rpc_module::Subscription> {
102-
self.0.subscribe(method, params).await.ok()
98+
json_query: &str,
99+
) -> Result<(String, mpsc::UnboundedReceiver<String>), JsonRpseeError> {
100+
self.0.raw_json_request(json_query).await
103101
}
104102

105103
/// Provides access to the underlying `RpcModule`

0 commit comments

Comments
 (0)