Skip to content

Commit 13dcb04

Browse files
committed
f cleaner hash conversion
1 parent 5f9390c commit 13dcb04

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lightning-block-sync/src/convert.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ impl TryInto<BlockHash> for BinaryResponse {
4949
type Error = std::io::Error;
5050

5151
fn try_into(self) -> std::io::Result<BlockHash> {
52-
if self.0.len() != 32 {
52+
BlockHash::from_slice(&self.0).map_err(|_|
5353
Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "bad block hash length"))
54-
} else {
55-
Ok(BlockHash::from_slice(&self.0).unwrap())
56-
}
54+
)?
5755
}
5856
}
5957

0 commit comments

Comments
 (0)