mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 12:27:56 +00:00
rpc: bump jsonrpsee v0.22 and fix race in rpc v2 chain_head (#3230)
Close #2992 Breaking changes: - rpc server grafana metric `substrate_rpc_requests_started` is removed (not possible to implement anymore) - rpc server grafana metric `substrate_rpc_requests_finished` is removed (not possible to implement anymore) - rpc server ws ping/pong not ACK:ed within 30 seconds more than three times then the connection will be closed Added - rpc server grafana metric `substrate_rpc_sessions_time` is added to get the duration for each websocket session
This commit is contained in:
@@ -38,7 +38,7 @@ use std::{collections::HashMap, net::SocketAddr};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use futures::{pin_mut, FutureExt, StreamExt};
|
||||
use jsonrpsee::{core::Error as JsonRpseeError, RpcModule};
|
||||
use jsonrpsee::RpcModule;
|
||||
use log::{debug, error, warn};
|
||||
use sc_client_api::{blockchain::HeaderBackend, BlockBackend, BlockchainEvents, ProofProvider};
|
||||
use sc_network::{
|
||||
@@ -109,17 +109,14 @@ impl RpcHandlers {
|
||||
pub async fn rpc_query(
|
||||
&self,
|
||||
json_query: &str,
|
||||
) -> Result<(String, tokio::sync::mpsc::Receiver<String>), JsonRpseeError> {
|
||||
) -> Result<(String, tokio::sync::mpsc::Receiver<String>), serde_json::Error> {
|
||||
// Because `tokio::sync::mpsc::channel` is used under the hood
|
||||
// it will panic if it's set to usize::MAX.
|
||||
//
|
||||
// This limit is used to prevent panics and is large enough.
|
||||
const TOKIO_MPSC_MAX_SIZE: usize = tokio::sync::Semaphore::MAX_PERMITS;
|
||||
|
||||
self.0
|
||||
.raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE)
|
||||
.await
|
||||
.map(|(method_res, recv)| (method_res.result, recv))
|
||||
self.0.raw_json_request(json_query, TOKIO_MPSC_MAX_SIZE).await
|
||||
}
|
||||
|
||||
/// Provides access to the underlying `RpcModule`
|
||||
|
||||
Reference in New Issue
Block a user