]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Somewhat simplify message handling error mapping in peer_handler
authorMatt Corallo <git@bluematt.me>
Thu, 17 Jun 2021 15:31:05 +0000 (15:31 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 21 Jun 2021 19:45:17 +0000 (19:45 +0000)
lightning/src/ln/peer_handler.rs

index c5128e25b055bab5b7be4f1e6651cd5501199144..ac6cef2926e21dbafef0a0ba4718006fdbf794f5 100644 (file)
@@ -966,27 +966,21 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref> PeerManager<D
                                self.message_handler.chan_handler.handle_announcement_signatures(&peer.their_node_id.unwrap(), &msg);
                        },
                        wire::Message::ChannelAnnouncement(msg) => {
-                               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));
                                }
                        },