Use ok_or for constants, rather than a redudant closure

* Use ok_or for constants in zebra-network
* Use ok_or for constants in zebra-consensus
This commit is contained in:
teor 2020-09-02 14:26:26 +10:00 committed by GitHub
parent 88557ddd0a
commit b5c653ed93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -15,7 +15,7 @@ pub fn is_coinbase_first(block: &Block) -> Result<(), Error> {
let first = block
.transactions
.get(0)
.ok_or_else(|| "block has no transactions")?;
.ok_or("block has no transactions")?;
let mut rest = block.transactions.iter().skip(1);
if !first.is_coinbase() {
return Err("first transaction must be coinbase".into());

View File

@ -262,7 +262,7 @@ where
let remote_msg = stream
.next()
.await
.ok_or_else(|| HandshakeError::ConnectionClosed)??;
.ok_or(HandshakeError::ConnectionClosed)??;
// Check that we got a Version and destructure its fields into the local scope.
debug!(?remote_msg, "got message from remote peer");
@ -295,7 +295,7 @@ where
let remote_msg = stream
.next()
.await
.ok_or_else(|| HandshakeError::ConnectionClosed)??;
.ok_or(HandshakeError::ConnectionClosed)??;
if let Message::Verack = remote_msg {
debug!("got verack from remote peer");
} else {