grpc-plugin: Make the grpc port to listen on configurable

Changelog-Added: cln-grpc-plugin: The plugin can be configured to listen on a specific port using the `grpc-port` option
This commit is contained in:
Christian Decker
2022-03-09 17:30:36 +01:00
committed by Rusty Russell
parent 647ed6a8c8
commit dd66c85fcb
3 changed files with 47 additions and 20 deletions

View File

@@ -331,6 +331,19 @@ where
sender: tokio::sync::mpsc::Sender<serde_json::Value>,
}
impl<S> Plugin<S>
where
S: Clone + Send,
{
pub fn option(&self, name: &str) -> Option<options::Value> {
self.options
.iter()
.filter(|o| o.name() == name)
.next()
.map(|co| co.value.clone().unwrap_or(co.default().clone()))
}
}
/// The [PluginDriver] is used to run the IO loop, reading messages
/// from the Lightning daemon, dispatching calls and notifications to
/// the plugin, and returning responses to the the daemon. We also use