clippy: add redundant_else clippy lint (#10525)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Thomas Coratger
2024-08-26 02:40:10 -07:00
committed by GitHub
parent 73a424205d
commit 9c57c4a454
12 changed files with 37 additions and 51 deletions

View File

@ -156,9 +156,8 @@ impl EngineHooksController {
);
return Poll::Ready(Ok(result))
} else {
debug!(target: "consensus::engine::hooks", hook = hook.name(), "Next hook is not ready");
}
debug!(target: "consensus::engine::hooks", hook = hook.name(), "Next hook is not ready");
Poll::Pending
}

View File

@ -51,10 +51,9 @@ where
tracing::warn!(target: "engine::stream::skip_fcu", ?state, ?payload_attrs, threshold=this.threshold, skipped=this.skipped, "Skipping FCU");
let _ = tx.send(Ok(OnForkChoiceUpdated::syncing()));
continue
} else {
*this.skipped = 0;
Some(BeaconEngineMessage::ForkchoiceUpdated { state, payload_attrs, tx })
}
*this.skipped = 0;
Some(BeaconEngineMessage::ForkchoiceUpdated { state, payload_attrs, tx })
}
next => next,
};

View File

@ -54,10 +54,9 @@ where
);
let _ = tx.send(Ok(PayloadStatus::from_status(PayloadStatusEnum::Syncing)));
continue
} else {
*this.skipped = 0;
Some(BeaconEngineMessage::NewPayload { payload, cancun_fields, tx })
}
*this.skipped = 0;
Some(BeaconEngineMessage::NewPayload { payload, cancun_fields, tx })
}
next => next,
};

View File

@ -599,10 +599,9 @@ impl Future for ActiveSession {
Poll::Ready(None) => {
if this.is_disconnecting() {
break
} else {
debug!(target: "net::session", remote_peer_id=?this.remote_peer_id, "eth stream completed");
return this.emit_disconnect(cx)
}
debug!(target: "net::session", remote_peer_id=?this.remote_peer_id, "eth stream completed");
return this.emit_disconnect(cx)
}
Poll::Ready(Some(res)) => {
match res {

View File

@ -275,9 +275,8 @@ impl TransactionFetcher {
// tx is really big, pack request with single tx
if size >= self.info.soft_limit_byte_size_pooled_transactions_response_on_pack_request {
return hashes_from_announcement_iter.collect::<RequestTxHashes>()
} else {
acc_size_response = size;
}
acc_size_response = size;
}
let mut surplus_hashes = RequestTxHashes::with_capacity(hashes_from_announcement_len - 1);
@ -692,14 +691,9 @@ impl TransactionFetcher {
Some(new_announced_hashes)
}
}
} else {
// stores a new request future for the request
self.inflight_requests.push(GetPooledTxRequestFut::new(
peer_id,
new_announced_hashes,
rx,
))
}
// stores a new request future for the request
self.inflight_requests.push(GetPooledTxRequestFut::new(peer_id, new_announced_hashes, rx));
None
}

View File

@ -53,14 +53,13 @@ impl Stream for ConsensusLayerHealthEvents {
if fork_choice.elapsed() <= NO_FORKCHOICE_UPDATE_RECEIVED_PERIOD {
// We had an FCU, and it's recent. CL is healthy.
continue
} else {
// We had an FCU, but it's too old.
return Poll::Ready(Some(
ConsensusLayerHealthEvent::HaveNotReceivedUpdatesForAWhile(
fork_choice.elapsed(),
),
))
}
// We had an FCU, but it's too old.
return Poll::Ready(Some(
ConsensusLayerHealthEvent::HaveNotReceivedUpdatesForAWhile(
fork_choice.elapsed(),
),
))
}
if let Some(transition_config) =

View File

@ -118,9 +118,8 @@ where
}
'inner: loop {
let mut drained = false;
// drain all calls that are ready and put them in the output item queue
if !this.pending_calls.is_empty() {
let drained = if !this.pending_calls.is_empty() {
if let Poll::Ready(Some(res)) = this.pending_calls.as_mut().poll_next(cx) {
let item = match res {
Ok(Some(resp)) => resp,
@ -128,11 +127,12 @@ where
Err(err) => err.into().to_string(),
};
this.items.push_back(item);
continue 'outer
} else {
drained = true;
continue 'outer;
}
}
true
} else {
false
};
// read from the stream
match this.conn.as_mut().poll_next(cx) {

View File

@ -273,9 +273,9 @@ mod tests {
// Continue from checkpoint
input.checkpoint = Some(checkpoint);
continue
} else {
assert_eq!(checkpoint.block_number, previous_stage);
assert_matches!(checkpoint.storage_hashing_stage_checkpoint(), Some(StorageHashingCheckpoint {
}
assert_eq!(checkpoint.block_number, previous_stage);
assert_matches!(checkpoint.storage_hashing_stage_checkpoint(), Some(StorageHashingCheckpoint {
progress: EntitiesCheckpoint {
processed,
total,
@ -284,14 +284,13 @@ mod tests {
}) if processed == total &&
total == runner.db.table::<tables::PlainStorageState>().unwrap().len() as u64);
// Validate the stage execution
assert!(
runner.validate_execution(input, Some(result)).is_ok(),
"execution validation"
);
// Validate the stage execution
assert!(
runner.validate_execution(input, Some(result)).is_ok(),
"execution validation"
);
break
}
break
}
panic!("Failed execution");
}

View File

@ -259,9 +259,8 @@ where
} else if block_number <= sharded_key.as_ref().highest_block_number {
// Filter out all elements greater than block number.
return Ok(list.iter().take_while(|i| *i < block_number).collect::<Vec<_>>())
} else {
return Ok(list.iter().collect::<Vec<_>>())
}
return Ok(list.iter().collect::<Vec<_>>())
}
Ok(Vec::new())
@ -1591,9 +1590,8 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
if done {
break true
} else {
deleted_entries += 1;
}
deleted_entries += 1;
};
Ok((deleted_entries, done))

View File

@ -57,9 +57,8 @@ impl<T: TransactionOrdering> Iterator for BestTransactionsWithFees<T> {
.map_or(true, |fee| fee >= self.base_fee_per_blob_gas as u128)
{
return Some(best);
} else {
crate::traits::BestTransactions::mark_invalid(self, &best);
}
crate::traits::BestTransactions::mark_invalid(self, &best);
}
}
}
@ -227,9 +226,8 @@ where
let best = self.best.next()?;
if (self.predicate)(&best) {
return Some(best)
} else {
self.best.mark_invalid(&best);
}
self.best.mark_invalid(&best);
}
}
}

View File

@ -75,6 +75,7 @@ pub fn state_root_unsorted<A: Into<TrieAccount>>(
}
/// Calculates the root hash of the state represented as MPT.
///
/// Corresponds to [geth's `deriveHash`](https://github.com/ethereum/go-ethereum/blob/6c149fd4ad063f7c24d726a73bc0546badd1bc73/core/genesis.go#L119).
///
/// # Panics