@@ -14,19 +14,19 @@ struct PluginState {
1414 rpc_path : PathBuf ,
1515 identity : tls:: Identity ,
1616 ca_cert : Vec < u8 > ,
17- events : broadcast:: Sender < cln_rpc:: notifications:: Notification > ,
17+ events : broadcast:: Sender < cln_rpc:: notifications:: Notification > ,
1818}
1919
20- const OPTION_GRPC_PORT : options:: IntegerConfigOption = options:: ConfigOption :: new_i64_no_default (
21- "grpc-port" ,
22- "Which port should the grpc plugin listen for incoming connections?" ) ;
20+ const OPTION_GRPC_PORT : options:: IntegerConfigOption = options:: ConfigOption :: new_i64_no_default (
21+ "grpc-port" ,
22+ "Which port should the grpc plugin listen for incoming connections?" ,
23+ ) ;
2324
2425const OPTION_GRPC_MSG_BUFFER_SIZE : options:: DefaultIntegerConfigOption = options:: ConfigOption :: new_i64_with_default (
2526 "grpc-msg-buffer-size" ,
2627 1024 ,
2728 "Number of notifications which can be stored in the grpc message buffer. Notifications can be skipped if this buffer is full" ) ;
2829
29-
3030#[ tokio:: main( flavor = "current_thread" ) ]
3131async fn main ( ) -> Result < ( ) > {
3232 debug ! ( "Starting grpc plugin" ) ;
@@ -57,21 +57,19 @@ async fn main() -> Result<()> {
5757 Some ( port) => port,
5858 None => {
5959 log:: info!( "'grpc-port' options i not configured. exiting." ) ;
60- plugin
61- . disable ( "Missing 'grpc-port' option" )
62- . await ?;
63- return Ok ( ( ) )
60+ plugin. disable ( "Missing 'grpc-port' option" ) . await ?;
61+ return Ok ( ( ) ) ;
6462 }
6563 } ;
6664
67- let buffer_size : i64 = plugin. option ( & OPTION_GRPC_MSG_BUFFER_SIZE ) . unwrap ( ) ;
65+ let buffer_size: i64 = plugin. option ( & OPTION_GRPC_MSG_BUFFER_SIZE ) . unwrap ( ) ;
6866 let buffer_size = match usize:: try_from ( buffer_size) {
6967 Ok ( b) => b,
7068 Err ( _) => {
7169 plugin
7270 . disable ( "'grpc-msg-buffer-size' should be strictly positive" )
7371 . await ?;
74- return Ok ( ( ) )
72+ return Ok ( ( ) ) ;
7573 }
7674 } ;
7775
@@ -83,7 +81,7 @@ async fn main() -> Result<()> {
8381 rpc_path : PathBuf :: from ( plugin. configuration ( ) . rpc_file . as_str ( ) ) ,
8482 identity,
8583 ca_cert,
86- events : sender
84+ events : sender,
8785 } ;
8886
8987 let plugin = plugin. start ( state. clone ( ) ) . await ?;
@@ -92,9 +90,9 @@ async fn main() -> Result<()> {
9290
9391 tokio:: select! {
9492 _ = plugin. join( ) => {
95- // This will likely never be shown, if we got here our
96- // parent process is exiting and not processing out log
97- // messages anymore.
93+ // This will likely never be shown, if we got here our
94+ // parent process is exiting and not processing out log
95+ // messages anymore.
9896 debug!( "Plugin loop terminated" )
9997 }
10098 e = run_interface( bind_addr, state) => {
@@ -112,15 +110,13 @@ async fn run_interface(bind_addr: SocketAddr, state: PluginState) -> Result<()>
112110 . identity ( identity)
113111 . client_ca_root ( ca_cert) ;
114112
115-
116113 let server = tonic:: transport:: Server :: builder ( )
117114 . tls_config ( tls)
118115 . context ( "configuring tls" ) ?
119- . add_service (
120- NodeServer :: new (
121- cln_grpc:: Server :: new ( & state. rpc_path , state. events . clone ( ) )
122- . await
123- . context ( "creating NodeServer instance" ) ?,
116+ . add_service ( NodeServer :: new (
117+ cln_grpc:: Server :: new ( & state. rpc_path , state. events . clone ( ) )
118+ . await
119+ . context ( "creating NodeServer instance" ) ?,
124120 ) )
125121 . serve ( bind_addr) ;
126122
@@ -134,18 +130,17 @@ async fn run_interface(bind_addr: SocketAddr, state: PluginState) -> Result<()>
134130 Ok ( ( ) )
135131}
136132
137- async fn handle_notification ( plugin : Plugin < PluginState > , value : serde_json:: Value ) -> Result < ( ) > {
138- let notification : Result < Notification , _ > = serde_json:: from_value ( value) ;
133+ async fn handle_notification ( plugin : Plugin < PluginState > , value : serde_json:: Value ) -> Result < ( ) > {
134+ let notification: Result < Notification , _ > = serde_json:: from_value ( value) ;
139135 match notification {
140- Err ( err) => {
136+ Err ( err) => {
141137 log:: debug!( "Failed to parse notification from lightningd {:?}" , err) ;
142- } ,
138+ }
143139 Ok ( notification) => {
144- match plugin. state ( ) . events . send ( notification) {
145- Err ( err) => log:: warn!( "Failed to broadcast notification {:?}" , err) ,
146- Ok ( _) => { } ,
140+ if let Err ( err) = plugin. state ( ) . events . send ( notification) {
141+ log:: warn!( "Failed to broadcast notification {:?}" , err)
147142 }
148143 }
149144 } ;
150145 Ok ( ( ) )
151- }
146+ }
0 commit comments