mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 18:11:10 +00:00
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:
@@ -13,9 +13,9 @@ readme = "README.md"
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
futures = "0.1.6"
|
||||
jsonrpc-core = "15.1.0"
|
||||
pubsub = { package = "jsonrpc-pubsub", version = "15.1.0" }
|
||||
futures = "0.3.16"
|
||||
jsonrpc-core = "18.0.0"
|
||||
pubsub = { package = "jsonrpc-pubsub", version = "18.0.0" }
|
||||
log = "0.4.8"
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.9.0"}
|
||||
serde = "1.0.126"
|
||||
@@ -23,6 +23,6 @@ serde_json = "1.0.41"
|
||||
sp-runtime = { version = "4.0.0-dev", path = "../../primitives/runtime" }
|
||||
|
||||
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
||||
http = { package = "jsonrpc-http-server", version = "15.1.0" }
|
||||
ipc = { package = "jsonrpc-ipc-server", version = "15.1.0" }
|
||||
ws = { package = "jsonrpc-ws-server", version = "15.1.0" }
|
||||
http = { package = "jsonrpc-http-server", version = "18.0.0" }
|
||||
ipc = { package = "jsonrpc-ipc-server", version = "18.0.0" }
|
||||
ws = { package = "jsonrpc-ws-server", version = "18.0.0" }
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user