Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
upbqdn committed Jan 13, 2025
1 parent 0fe47bb commit c897e59
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
6 changes: 3 additions & 3 deletions zebra-network/src/protocol/external/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl Codec {

writer.write_u64::<LittleEndian>(nonce.0)?;

if user_agent.as_bytes().len() > MAX_USER_AGENT_LENGTH {
if user_agent.len() > MAX_USER_AGENT_LENGTH {
// zcashd won't accept this version message
return Err(Error::Parse(
"user agent too long: must be 256 bytes or less",
Expand All @@ -248,7 +248,7 @@ impl Codec {
reason,
data,
} => {
if message.as_bytes().len() > MAX_REJECT_MESSAGE_LENGTH {
if message.len() > MAX_REJECT_MESSAGE_LENGTH {
// zcashd won't accept this reject message
return Err(Error::Parse(
"reject message too long: must be 12 bytes or less",
Expand All @@ -259,7 +259,7 @@ impl Codec {

writer.write_u8(*ccode as u8)?;

if reason.as_bytes().len() > MAX_REJECT_REASON_LENGTH {
if reason.len() > MAX_REJECT_REASON_LENGTH {
return Err(Error::Parse(
"reject reason too long: must be 111 bytes or less",
));
Expand Down
2 changes: 1 addition & 1 deletion zebra-rpc/src/server/http_request_compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<S> HttpRequestMiddleware<S> {
.and_then(|encoded| URL_SAFE.decode(encoded).ok())
.and_then(|decoded| String::from_utf8(decoded).ok())
.and_then(|request_cookie| request_cookie.split(':').nth(1).map(String::from))
.map_or(false, |passwd| internal_cookie.authenticate(passwd))
.is_some_and(|passwd| internal_cookie.authenticate(passwd))
})
}

Expand Down
42 changes: 18 additions & 24 deletions zebra-state/src/service/non_finalized_state/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,14 @@ impl Chain {
let anchor = tree.root();
trace!(?height, ?anchor, "adding sprout tree");

// Don't add a new tree unless it differs from the previous one or there's no previous tree.
// Add the new tree only if:
//
// - it differs from the previous one, or
// - there's no previous tree.
if height.is_min()
|| self
.sprout_tree(
height
.previous()
.expect("Already checked for underflow.")
.into(),
)
.map_or(true, |prev_tree| prev_tree != tree)
.sprout_tree(height.previous().expect("prev height").into())
.is_none_or(|prev_tree| prev_tree != tree)
{
assert_eq!(
self.sprout_trees_by_height.insert(height, tree.clone()),
Expand Down Expand Up @@ -756,16 +754,14 @@ impl Chain {
let anchor = tree.root();
trace!(?height, ?anchor, "adding sapling tree");

// Don't add a new tree unless it differs from the previous one or there's no previous tree.
// Add the new tree only if:
//
// - it differs from the previous one, or
// - there's no previous tree.
if height.is_min()
|| self
.sapling_tree(
height
.previous()
.expect("Already checked for underflow.")
.into(),
)
.map_or(true, |prev_tree| prev_tree != tree)
.sapling_tree(height.previous().expect("prev height").into())
.is_none_or(|prev_tree| prev_tree != tree)
{
assert_eq!(
self.sapling_trees_by_height.insert(height, tree),
Expand Down Expand Up @@ -963,16 +959,14 @@ impl Chain {
let anchor = tree.root();
trace!(?height, ?anchor, "adding orchard tree");

// Don't add a new tree unless it differs from the previous one or there's no previous tree.
// Add the new tree only if:
//
// - it differs from the previous one, or
// - there's no previous tree.
if height.is_min()
|| self
.orchard_tree(
height
.previous()
.expect("Already checked for underflow.")
.into(),
)
.map_or(true, |prev_tree| prev_tree != tree)
.orchard_tree(height.previous().expect("prev height").into())
.is_none_or(|prev_tree| prev_tree != tree)
{
assert_eq!(
self.orchard_trees_by_height.insert(height, tree),
Expand Down

0 comments on commit c897e59

Please sign in to comment.