mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +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:
@@ -18,28 +18,27 @@
|
||||
|
||||
//! Substrate system API.
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use futures::{channel::oneshot, compat::Compat, future::BoxFuture, FutureExt, TryFutureExt};
|
||||
use self::error::Result;
|
||||
use futures::{channel::oneshot, FutureExt};
|
||||
use sc_rpc_api::{DenyUnsafe, Receiver};
|
||||
use sc_tracing::logging;
|
||||
use sp_runtime::traits::{self, Header as HeaderT};
|
||||
use sp_utils::mpsc::TracingUnboundedSender;
|
||||
|
||||
use self::error::Result;
|
||||
|
||||
pub use self::{
|
||||
gen_client::Client as SystemClient,
|
||||
helpers::{Health, NodeRole, PeerInfo, SyncState, SystemInfo},
|
||||
};
|
||||
pub use sc_rpc_api::system::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
/// Early exit for RPCs that require `--rpc-methods=Unsafe` to be enabled
|
||||
macro_rules! bail_if_unsafe {
|
||||
($value: expr) => {
|
||||
if let Err(err) = $value.check_if_safe() {
|
||||
return async move { Err(err.into()) }.boxed().compat()
|
||||
return async move { Err(err.into()) }.boxed()
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -114,51 +113,42 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
|
||||
fn system_health(&self) -> Receiver<Health> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::Health(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
Receiver(rx)
|
||||
}
|
||||
|
||||
fn system_local_peer_id(&self) -> Receiver<String> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::LocalPeerId(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
Receiver(rx)
|
||||
}
|
||||
|
||||
fn system_local_listen_addresses(&self) -> Receiver<Vec<String>> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::LocalListenAddresses(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
Receiver(rx)
|
||||
}
|
||||
|
||||
fn system_peers(
|
||||
&self,
|
||||
) -> Compat<
|
||||
BoxFuture<'static, rpc::Result<Vec<PeerInfo<B::Hash, <B::Header as HeaderT>::Number>>>>,
|
||||
> {
|
||||
) -> rpc::BoxFuture<rpc::Result<Vec<PeerInfo<B::Hash, <B::Header as HeaderT>::Number>>>> {
|
||||
bail_if_unsafe!(self.deny_unsafe);
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::Peers(tx));
|
||||
|
||||
async move { rx.await.map_err(|_| rpc::Error::internal_error()) }
|
||||
.boxed()
|
||||
.compat()
|
||||
async move { rx.await.map_err(|_| rpc::Error::internal_error()) }.boxed()
|
||||
}
|
||||
|
||||
fn system_network_state(&self) -> Compat<BoxFuture<'static, rpc::Result<rpc::Value>>> {
|
||||
fn system_network_state(&self) -> rpc::BoxFuture<rpc::Result<rpc::Value>> {
|
||||
bail_if_unsafe!(self.deny_unsafe);
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::NetworkState(tx));
|
||||
|
||||
async move { rx.await.map_err(|_| rpc::Error::internal_error()) }
|
||||
.boxed()
|
||||
.compat()
|
||||
async move { rx.await.map_err(|_| rpc::Error::internal_error()) }.boxed()
|
||||
}
|
||||
|
||||
fn system_add_reserved_peer(
|
||||
&self,
|
||||
peer: String,
|
||||
) -> Compat<BoxFuture<'static, std::result::Result<(), rpc::Error>>> {
|
||||
fn system_add_reserved_peer(&self, peer: String) -> rpc::BoxFuture<rpc::Result<()>> {
|
||||
bail_if_unsafe!(self.deny_unsafe);
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -171,13 +161,9 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
|
||||
}
|
||||
}
|
||||
.boxed()
|
||||
.compat()
|
||||
}
|
||||
|
||||
fn system_remove_reserved_peer(
|
||||
&self,
|
||||
peer: String,
|
||||
) -> Compat<BoxFuture<'static, std::result::Result<(), rpc::Error>>> {
|
||||
fn system_remove_reserved_peer(&self, peer: String) -> rpc::BoxFuture<rpc::Result<()>> {
|
||||
bail_if_unsafe!(self.deny_unsafe);
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -190,34 +176,33 @@ impl<B: traits::Block> SystemApi<B::Hash, <B::Header as HeaderT>::Number> for Sy
|
||||
}
|
||||
}
|
||||
.boxed()
|
||||
.compat()
|
||||
}
|
||||
|
||||
fn system_reserved_peers(&self) -> Receiver<Vec<String>> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::NetworkReservedPeers(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
Receiver(rx)
|
||||
}
|
||||
|
||||
fn system_node_roles(&self) -> Receiver<Vec<NodeRole>> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::NodeRoles(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
Receiver(rx)
|
||||
}
|
||||
|
||||
fn system_sync_state(&self) -> Receiver<SyncState<<B::Header as HeaderT>::Number>> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let _ = self.send_back.unbounded_send(Request::SyncState(tx));
|
||||
Receiver(Compat::new(rx))
|
||||
Receiver(rx)
|
||||
}
|
||||
|
||||
fn system_add_log_filter(&self, directives: String) -> std::result::Result<(), rpc::Error> {
|
||||
fn system_add_log_filter(&self, directives: String) -> rpc::Result<()> {
|
||||
self.deny_unsafe.check_if_safe()?;
|
||||
logging::add_directives(&directives);
|
||||
logging::reload_filter().map_err(|_e| rpc::Error::internal_error())
|
||||
}
|
||||
|
||||
fn system_reset_log_filter(&self) -> std::result::Result<(), rpc::Error> {
|
||||
fn system_reset_log_filter(&self) -> rpc::Result<()> {
|
||||
self.deny_unsafe.check_if_safe()?;
|
||||
logging::reset_log_filter().map_err(|_e| rpc::Error::internal_error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user