Upgrade jsonrpc to 0.18.0 (#9547)

* Upgrade jsonrpc to 0.18.0

I think this says all :P

* 🤦

* Fmt etc

* Fix tests

* Fix tests again...

* Better impl

* Revert "Tell dependabot to ignore jsonrpc-* updates (#9518)"

This reverts commit 6e0cd5587d.
This commit is contained in:
Bastian Köcher
2021-08-13 08:46:07 +02:00
committed by GitHub
parent 199b2883af
commit c44aba89e6
65 changed files with 1422 additions and 1291 deletions
+19 -19
View File
@@ -37,7 +37,7 @@ mod task_manager;
use std::{collections::HashMap, io, net::SocketAddr, pin::Pin, task::Poll};
use codec::{Decode, Encode};
use futures::{compat::*, stream, Future, FutureExt, Stream, StreamExt};
use futures::{stream, Future, FutureExt, Stream, StreamExt};
use log::{debug, error, warn};
use parity_util_mem::MallocSizeOf;
use sc_network::PeerId;
@@ -112,11 +112,7 @@ impl RpcHandlers {
mem: &RpcSession,
request: &str,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send>> {
self.0
.handle_request(request, mem.metadata.clone())
.compat()
.map(|res| res.expect("this should never fail"))
.boxed()
self.0.handle_request(request, mem.metadata.clone()).boxed()
}
/// Provides access to the underlying `MetaIoHandler`
@@ -354,7 +350,7 @@ fn start_rpc_servers<
config: &Configuration,
mut gen_handler: H,
rpc_metrics: sc_rpc_server::RpcMetrics,
) -> Result<Box<dyn std::any::Any + Send + Sync>, Error> {
) -> Result<Box<dyn std::any::Any + Send>, Error> {
fn maybe_start_server<T, F>(
address: Option<SocketAddr>,
mut start: F,
@@ -388,16 +384,20 @@ fn start_rpc_servers<
}
Ok(Box::new((
config.rpc_ipc.as_ref().map(|path| {
sc_rpc_server::start_ipc(
&*path,
gen_handler(
sc_rpc::DenyUnsafe::No,
sc_rpc_server::RpcMiddleware::new(rpc_metrics.clone(), "ipc"),
)?,
)
.map_err(Error::from)
}),
config
.rpc_ipc
.as_ref()
.map(|path| {
sc_rpc_server::start_ipc(
&*path,
gen_handler(
sc_rpc::DenyUnsafe::No,
sc_rpc_server::RpcMiddleware::new(rpc_metrics.clone(), "ipc"),
)?,
)
.map_err(Error::from)
})
.transpose()?,
maybe_start_server(config.rpc_http, |address| {
sc_rpc_server::start_http(
address,
@@ -441,7 +441,7 @@ fn start_rpc_servers<
_: &Configuration,
_: H,
_: sc_rpc_server::RpcMetrics,
) -> Result<Box<dyn std::any::Any + Send + Sync>, error::Error> {
) -> Result<Box<dyn std::any::Any + Send>, error::Error> {
Ok(Box::new(()))
}
@@ -459,7 +459,7 @@ impl RpcSession {
/// messages.
///
/// The `RpcSession` must be kept alive in order to receive messages on the sender.
pub fn new(sender: futures01::sync::mpsc::Sender<String>) -> RpcSession {
pub fn new(sender: futures::channel::mpsc::UnboundedSender<String>) -> RpcSession {
RpcSession { metadata: sender.into() }
}
}