mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 04:11:07 +00:00
Add IPC support (#6348)
This is useful for both security and performance reasons. IPC is faster than TCP, and it is subject to OS access controls.
This commit is contained in:
@@ -67,6 +67,8 @@ pub struct Configuration {
|
||||
pub rpc_http: Option<SocketAddr>,
|
||||
/// RPC over Websockets binding address. `None` if disabled.
|
||||
pub rpc_ws: Option<SocketAddr>,
|
||||
/// RPC over IPC binding path. `None` if disabled.
|
||||
pub rpc_ipc: Option<String>,
|
||||
/// Maximum number of connections for WebSockets RPC server. `None` if default.
|
||||
pub rpc_ws_max_connections: Option<usize>,
|
||||
/// CORS settings for HTTP & WS servers. `None` if all origins are allowed.
|
||||
|
||||
@@ -510,6 +510,16 @@ mod waiting {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct IpcServer(pub Option<sc_rpc_server::IpcServer>);
|
||||
impl Drop for IpcServer {
|
||||
fn drop(&mut self) {
|
||||
if let Some(server) = self.0.take() {
|
||||
server.close_handle().close();
|
||||
let _ = server.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WsServer(pub Option<sc_rpc_server::WsServer>);
|
||||
impl Drop for WsServer {
|
||||
fn drop(&mut self) {
|
||||
@@ -555,6 +565,7 @@ fn start_rpc_servers<H: FnMut(sc_rpc::DenyUnsafe) -> sc_rpc_server::RpcHandler<s
|
||||
}
|
||||
|
||||
Ok(Box::new((
|
||||
config.rpc_ipc.as_ref().map(|path| sc_rpc_server::start_ipc(&*path, gen_handler(sc_rpc::DenyUnsafe::No))),
|
||||
maybe_start_server(
|
||||
config.rpc_http,
|
||||
|address| sc_rpc_server::start_http(
|
||||
|
||||
Reference in New Issue
Block a user