@@ -37,13 +37,12 @@ mod task_manager;
3737use std:: { collections:: HashMap , net:: SocketAddr , pin:: Pin , task:: Poll } ;
3838
3939use 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 } ;
4242use log:: { debug, error, warn} ;
4343use sc_client_api:: { blockchain:: HeaderBackend , BlockchainEvents } ;
4444use sc_network:: PeerId ;
4545use sc_utils:: mpsc:: TracingUnboundedReceiver ;
46- use serde:: Serialize ;
4746use sp_runtime:: {
4847 generic:: BlockId ,
4948 traits:: { Block as BlockT , Header as HeaderT } ,
@@ -87,19 +86,18 @@ pub struct RpcHandlers(Arc<RpcModule<()>>);
8786impl 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