From 9127f94413595950414faf79ad488f9ca4b145f7 Mon Sep 17 00:00:00 2001 From: jackstar12 Date: Sun, 21 Jul 2024 19:31:47 +0200 Subject: [PATCH] plugins/grpc: default value for grpc port --- plugins/grpc-plugin/src/main.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/plugins/grpc-plugin/src/main.rs b/plugins/grpc-plugin/src/main.rs index c71847fc6f98..ecc74c90d633 100644 --- a/plugins/grpc-plugin/src/main.rs +++ b/plugins/grpc-plugin/src/main.rs @@ -17,8 +17,9 @@ struct PluginState { events : broadcast::Sender, } -const OPTION_GRPC_PORT : options::IntegerConfigOption = options::ConfigOption::new_i64_no_default( - "grpc-port", +const OPTION_GRPC_PORT : options::DefaultIntegerConfigOption = options::ConfigOption::new_i64_with_default( + "grpc-port", + 9736, "Which port should the grpc plugin listen for incoming connections?"); const OPTION_GRPC_MSG_BUFFER_SIZE : options::DefaultIntegerConfigOption = options::ConfigOption::new_i64_with_default( @@ -53,17 +54,7 @@ async fn main() -> Result<()> { None => return Ok(()), }; - let bind_port = match plugin.option(&OPTION_GRPC_PORT).unwrap() { - Some(port) => port, - None => { - log::info!("'grpc-port' options i not configured. exiting."); - plugin - .disable("Missing 'grpc-port' option") - .await?; - return Ok(()) - } - }; - + let bind_port : i64 = plugin.option(&OPTION_GRPC_PORT).unwrap(); let buffer_size : i64 = plugin.option(&OPTION_GRPC_MSG_BUFFER_SIZE).unwrap(); let buffer_size = match usize::try_from(buffer_size) { Ok(b) => b, @@ -137,7 +128,7 @@ async fn run_interface(bind_addr: SocketAddr, state: PluginState) -> Result<()> async fn handle_notification(plugin : Plugin, value : serde_json::Value) -> Result<()> { let notification : Result = serde_json::from_value(value); match notification { - Err(err) => { + Err(err) => { log::debug!("Failed to parse notification from lightningd {:?}", err); }, Ok(notification) => { @@ -148,4 +139,4 @@ async fn handle_notification(plugin : Plugin, value : serde_json::V } }; Ok(()) -} \ No newline at end of file +}