From: Matt Corallo Date: Thu, 17 Jun 2021 15:31:05 +0000 (+0000) Subject: Somewhat simplify message handling error mapping in peer_handler X-Git-Tag: v0.0.99~19^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=f76e14c4256550f39421ec0ed14bbe796d072f13;p=rust-lightning Somewhat simplify message handling error mapping in peer_handler --- diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index c5128e25b..ac6cef292 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -966,27 +966,21 @@ impl PeerManager { - if match self.message_handler.route_handler.handle_channel_announcement(&msg) { - Ok(v) => v, - Err(e) => { return Err(e.into()); }, - } { + if self.message_handler.route_handler.handle_channel_announcement(&msg) + .map_err(|e| -> MessageHandlingError { e.into() })? { should_forward = Some(wire::Message::ChannelAnnouncement(msg)); } }, wire::Message::NodeAnnouncement(msg) => { - if match self.message_handler.route_handler.handle_node_announcement(&msg) { - Ok(v) => v, - Err(e) => { return Err(e.into()); }, - } { + if self.message_handler.route_handler.handle_node_announcement(&msg) + .map_err(|e| -> MessageHandlingError { e.into() })? { should_forward = Some(wire::Message::NodeAnnouncement(msg)); } }, wire::Message::ChannelUpdate(msg) => { self.message_handler.chan_handler.handle_channel_update(&peer.their_node_id.unwrap(), &msg); - if match self.message_handler.route_handler.handle_channel_update(&msg) { - Ok(v) => v, - Err(e) => { return Err(e.into()); }, - } { + if self.message_handler.route_handler.handle_channel_update(&msg) + .map_err(|e| -> MessageHandlingError { e.into() })? { should_forward = Some(wire::Message::ChannelUpdate(msg)); } },