From 701da1363cb2ba4250a434b49a253fbec38347c8 Mon Sep 17 00:00:00 2001 From: Dom Dwyer Date: Mon, 10 Jul 2023 14:10:03 +0200 Subject: [PATCH] refactor: remove panic on impossible error Remove the logical complexity of error handling for an error that cannot occur. This was an artifact of pre-PR refactoring - the error being returned SHOULD never be reached, as the only error returned is the "your message is too big" error, and that's not possible because the message size is validated in the GossipHandle::broadcast() method before it reaches the reactor. --- gossip/src/reactor.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gossip/src/reactor.rs b/gossip/src/reactor.rs index d547df6d6e..990b8d3eda 100644 --- a/gossip/src/reactor.rs +++ b/gossip/src/reactor.rs @@ -213,15 +213,18 @@ where // The user is guaranteed MAX_USER_PAYLOAD_BYTES to // be send-able, so send this frame without packing // others with it for simplicity. - if populate_frame( + populate_frame( &mut self.cached_frame, vec![new_payload(Payload::UserData(proto::UserPayload{payload}))], &mut self.serialisation_buf - ).is_err() - { - continue - } - self.peer_list.broadcast(&self.serialisation_buf, &self.socket, &self.metric_frames_sent, &self.metric_bytes_sent).await; + ).expect("size validated in handle at enqueue time"); + + self.peer_list.broadcast( + &self.serialisation_buf, + &self.socket, + &self.metric_frames_sent, + &self.metric_bytes_sent + ).await; } } }