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
+10 -6
View File
@@ -61,10 +61,13 @@ pub fn rpc_handler<M: PubSubMetadata>(
.expect("Serialization of Vec<String> is infallible; qed");
move |_| {
Ok(serde_json::json!({
"version": 1,
"methods": methods.clone(),
}))
let methods = methods.clone();
async move {
Ok(serde_json::json!({
"version": 1,
"methods": methods,
}))
}
}
});
io
@@ -84,7 +87,7 @@ mod inner {
/// Start HTTP server listening on given address.
///
/// **Note**: Only available if `not(target_os = "unknown")`.
pub fn start_http<M: pubsub::PubSubMetadata + Default>(
pub fn start_http<M: pubsub::PubSubMetadata + Default + Unpin>(
addr: &std::net::SocketAddr,
thread_pool_size: Option<usize>,
cors: Option<&Vec<String>>,
@@ -94,6 +97,7 @@ mod inner {
let max_request_body_size = maybe_max_payload_mb
.map(|mb| mb.saturating_mul(MEGABYTE))
.unwrap_or(RPC_MAX_PAYLOAD_DEFAULT);
http::ServerBuilder::new(io)
.threads(thread_pool_size.unwrap_or(HTTP_THREADS))
.health_api(("/health", "system_health"))
@@ -125,7 +129,7 @@ mod inner {
///
/// **Note**: Only available if `not(target_os = "unknown")`.
pub fn start_ws<
M: pubsub::PubSubMetadata + From<jsonrpc_core::futures::sync::mpsc::Sender<String>>,
M: pubsub::PubSubMetadata + From<futures::channel::mpsc::UnboundedSender<String>>,
>(
addr: &std::net::SocketAddr,
max_connections: Option<usize>,
@@ -73,12 +73,12 @@ impl<M: Metadata> RequestMiddleware<M> for RpcMiddleware {
fn on_request<F, X>(&self, request: Request, meta: M, next: F) -> Either<FutureResponse, X>
where
F: Fn(Request, M) -> X + Send + Sync,
X: Future<Item = Option<Response>, Error = ()> + Send + 'static,
X: Future<Output = Option<Response>> + Send + 'static,
{
if let Some(ref rpc_calls) = self.metrics.rpc_calls {
rpc_calls.with_label_values(&[self.transport_label.as_str()]).inc();
}
Either::B(next(request, meta))
Either::Right(next(request, meta))
}
}