Skip to content

Commit 5fcb657

Browse files
committed
refactor: simplify code
1 parent 3e96557 commit 5fcb657

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

crates/net/p2p/src/full_block.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,10 @@ where
145145

146146
/// Returns the [`SealedBlock`] if the request is complete and valid.
147147
fn take_block(&mut self) -> Option<SealedBlock<Client::Block>> {
148-
if self.header.is_none() || self.body.is_none() {
149-
return None
150-
}
151-
152-
let header = self.header.take().unwrap();
153-
let resp = self.body.take().unwrap();
148+
let (header, resp) = match (self.header.as_ref(), self.body.as_ref()) {
149+
(Some(_), Some(_)) => (self.header.take().unwrap(), self.body.take().unwrap()),
150+
_ => return None,
151+
};
154152
match resp {
155153
BodyResponse::Validated(body) => Some(SealedBlock::from_sealed_parts(header, body)),
156154
BodyResponse::PendingValidation(resp) => {

0 commit comments

Comments
 (0)