Skip to content

Commit

Permalink
plugins/grpc: default value for grpc port
Browse files Browse the repository at this point in the history
Changelog-Changed: grpc now starts on port 9736 by default
  • Loading branch information
jackstar12 committed Aug 12, 2024
1 parent a243f3c commit b8c5779
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 2 additions & 0 deletions contrib/pyln-testing/pyln/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@ def __init__(

if grpc_port is not None:
opts['grpc-port'] = grpc_port
else:
opts['disable-plugin'] = 'cln-grpc'

for k, v in opts.items():
self.opts[k] = v
Expand Down
15 changes: 4 additions & 11 deletions plugins/grpc-plugin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ struct PluginState {
events: broadcast::Sender<cln_rpc::notifications::Notification>,
}

const OPTION_GRPC_PORT: options::IntegerConfigOption = options::ConfigOption::new_i64_no_default(
const OPTION_GRPC_PORT: options::DefaultIntegerConfigOption = options::ConfigOption::new_i64_with_default(
"grpc-port",
"Which port should the grpc plugin listen for incoming connections?",
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(
Expand Down Expand Up @@ -53,15 +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,
Expand Down

0 comments on commit b8c5779

Please sign in to comment.