(bind_addr: SocketAddr, state: PluginState)
| 141 | } |
| 142 | |
| 143 | async fn run_interface(bind_addr: SocketAddr, state: PluginState) -> Result<()> { |
| 144 | let identity = state.identity.to_tonic_identity(); |
| 145 | let ca_cert = tonic::transport::Certificate::from_pem(state.ca_cert); |
| 146 | |
| 147 | let tls = tonic::transport::ServerTlsConfig::new() |
| 148 | .identity(identity) |
| 149 | .client_ca_root(ca_cert); |
| 150 | |
| 151 | let server = tonic::transport::Server::builder() |
| 152 | .tls_config(tls) |
| 153 | .context("configuring tls")? |
| 154 | .add_service(NodeServer::new( |
| 155 | cln_grpc::Server::new(&state.rpc_path, state.events.clone()) |
| 156 | .await |
| 157 | .context("creating NodeServer instance")?, |
| 158 | )) |
| 159 | .serve(bind_addr); |
| 160 | |
| 161 | log::info!( |
| 162 | "Connecting to {:?} and serving grpc on {:?}", |
| 163 | &state.rpc_path, |
| 164 | &bind_addr |
| 165 | ); |
| 166 | |
| 167 | server.await.context("serving requests")?; |
| 168 | |
| 169 | Ok(()) |
| 170 | } |
| 171 | |
| 172 | async fn handle_notification(plugin: Plugin<PluginState>, value: serde_json::Value) -> Result<()> { |
| 173 | let notification: Result<Notification, _> = serde_json::from_value(value); |
nothing calls this directly
no test coverage detected