Handle RPC requests in the substrate-service (#2866)

* Rework RPC queries

* Remove SyncProvider trait

* Fix RPC tests
This commit is contained in:
Pierre Krieger
2019-06-15 15:44:04 +02:00
committed by Gavin Wood
parent c48aebe897
commit f7bd56d2a8
10 changed files with 180 additions and 133 deletions
+4 -5
View File
@@ -34,6 +34,7 @@ use crate::config::Configuration;
use primitives::{Blake2Hasher, H256};
use rpc::{self, apis::system::SystemInfo};
use parking_lot::Mutex;
use futures::sync::mpsc;
// Type aliases.
// These exist mainly to avoid typing `<F as Factory>::Foo` all over the code.
@@ -139,8 +140,7 @@ pub trait StartRPC<C: Components> {
fn start_rpc(
client: Arc<ComponentClient<C>>,
network: Arc<dyn network::SyncProvider<ComponentBlock<C>>>,
should_have_peers: bool,
system_send_back: mpsc::UnboundedSender<rpc::apis::system::Request<ComponentBlock<C>>>,
system_info: SystemInfo,
rpc_http: Option<SocketAddr>,
rpc_ws: Option<SocketAddr>,
@@ -159,8 +159,7 @@ impl<C: Components> StartRPC<Self> for C where
fn start_rpc(
client: Arc<ComponentClient<C>>,
network: Arc<dyn network::SyncProvider<ComponentBlock<C>>>,
should_have_peers: bool,
system_send_back: mpsc::UnboundedSender<rpc::apis::system::Request<ComponentBlock<C>>>,
rpc_system_info: SystemInfo,
rpc_http: Option<SocketAddr>,
rpc_ws: Option<SocketAddr>,
@@ -178,7 +177,7 @@ impl<C: Components> StartRPC<Self> for C where
client.clone(), transaction_pool.clone(), subscriptions
);
let system = rpc::apis::system::System::new(
rpc_system_info.clone(), network.clone(), should_have_peers
rpc_system_info.clone(), system_send_back.clone()
);
rpc::rpc_handler::<ComponentBlock<C>, ComponentExHash<C>, _, _, _, _>(
state,