Skip to content

Commit

Permalink
chore: fix lint and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
j75689 committed Jun 20, 2024
1 parent cd753d6 commit 09b9cbb
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
8 changes: 4 additions & 4 deletions crates/bsc/consensus/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ impl HeadersClient for ParliaClient {
let this = self.clone();
Box::pin(async move {
let result = this.fetch_headers(request.clone()).await;
if !result.is_err() {
if result.is_ok() {
let headers = result.clone().unwrap();
if headers.len() as u64 == request.limit {
return Ok(WithPeerId::new(PeerId::random(), headers.clone()));
return Ok(WithPeerId::new(PeerId::random(), headers));
}
}
this.fetch_client.get_headers_with_priority(request.clone(), priority).await
Expand All @@ -130,8 +130,8 @@ impl BodiesClient for ParliaClient {
let this = self.clone();
Box::pin(async move {
let result = this.fetch_bodies(hashes.clone()).await;
if !result.is_err() {
return Ok(WithPeerId::new(PeerId::random(), result.unwrap().clone()));
if result.is_ok() {
return Ok(WithPeerId::new(PeerId::random(), result.unwrap()));
}
this.fetch_client.get_block_bodies_with_priority(hashes.clone(), priority).await
})
Expand Down
4 changes: 2 additions & 2 deletions crates/bsc/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ impl<Client, Engine> ParliaEngineBuilder<Client, Engine>
let parlia_client = ParliaClient::new(storage.clone(), fetch_client);
let task = ParliaEngineTask::new(
chain_spec.clone(),
Parlia::new(chain_spec.clone(), cfg),
Parlia::new(chain_spec, cfg),
to_engine,
network_block_event_rx,
storage,
Expand Down Expand Up @@ -766,7 +766,7 @@ impl<K, V> LimitedHashSet<K, V>
}

fn get(&self, key: &K) -> Option<&V> {
self.map.get(key).map(|v| v)
self.map.get(key)
}

fn iter(&self) -> impl Iterator<Item = (&K, &V)> {
Expand Down
8 changes: 4 additions & 4 deletions crates/bsc/consensus/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ impl<Engine: EngineTypes+ 'static> ParliaEngineTask<Engine> {
EngineMessage::NewBlockHashes(event) => match event.hashes.last() {
None => continue,
Some(block_hash) => {
info.block_hash = BlockHashOrNumber::Hash(block_hash.hash.clone());
info.block_hash = BlockHashOrNumber::Hash(block_hash.hash);
info.block_number = block_hash.number;
}
},
EngineMessage::NewBlock(event) => {
info.block_hash = BlockHashOrNumber::Hash(event.hash.clone());
info.block_hash = BlockHashOrNumber::Hash(event.hash);
info.block_number = event.block.block.number;
info.block = Some(event.block.block.clone());
}
Expand Down Expand Up @@ -164,7 +164,7 @@ impl<Engine: EngineTypes+ 'static> ParliaEngineTask<Engine> {
debug!(target: "consensus::parlia", { block_hash = ?info.block_hash }, "Fetching new header");
// fetch header and verify
let fetch_header_result = block_fetcher
.get_header_with_priority(info.block_hash.into(), Priority::High)
.get_header_with_priority(info.block_hash, Priority::High)
.await;
if fetch_header_result.is_err() {
trace!(target: "consensus::parlia", "Failed to fetch header");
Expand Down Expand Up @@ -229,7 +229,7 @@ impl<Engine: EngineTypes+ 'static> ParliaEngineTask<Engine> {
ForkChoiceMessage::NewBlock(event) => {
// notify beacon engine
let state = ForkchoiceState {
head_block_hash: event.hash.clone(),
head_block_hash: event.hash,
// safe(justified) and finalized hash will be determined in the parlia consensus engine and stored in the snapshot after the block sync
safe_block_hash: B256::ZERO,
finalized_block_hash: B256::ZERO,
Expand Down
1 change: 0 additions & 1 deletion crates/config/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Configuration files.
#[cfg(feature = "bsc")]
use reth_primitives::parlia::ParliaConfig;
use reth_network::{PeersConfig, SessionsConfig};
use reth_prune_types::PruneModes;
Expand Down
8 changes: 4 additions & 4 deletions crates/net/network/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ where
Arc::clone(&num_active_peers),
Arc::new(Mutex::new(listener_addr)),
to_manager_tx,
mutex_engine_rx.clone(),
mutex_engine_rx,
secret_key,
local_peer_id,
peers_handle,
Expand Down Expand Up @@ -538,7 +538,7 @@ where
self.swarm.state_mut().on_new_block_hashes(peer_id, hashes.clone().0);
// notify task engine
self.notify_engine_task(EngineMessage::NewBlockHashes(BlockHashesEvent{
hashes: hashes.clone().into(),
hashes: hashes.into(),
}));
}
#[cfg(feature = "bsc")]
Expand All @@ -548,8 +548,8 @@ where
self.block_import.on_new_block(peer_id, block.clone());
// notify task engine
self.notify_engine_task(EngineMessage::NewBlock(BlockEvent{
hash: block.hash.clone(),
block: block.block.clone(),
hash: block.hash,
block: block.block,
}));
}
PeerMessage::PooledTransactions(msg) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl fmt::Debug for PeerRequestSender {
}
}

/// All message variants that can be sent to TaskEngine.
/// All message variants that can be sent to `TaskEngine`.
#[derive(Debug)]
pub enum EngineMessage {
/// Announce new block hashes
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) const NETWORK_POOL_TRANSACTIONS_SCOPE: &str = "network.pool.transacti
/// Scope for monitoring transactions sent from the manager to the tx manager
pub(crate) const NETWORK_PEER_SCOPE: &str = "network.peer.message";

/// Metrics for the entire network, handled by NetworkManager
/// Metrics for the entire network, handled by `NetworkManager`
#[derive(Metrics)]
#[metrics(scope = "network")]
pub struct NetworkMetrics {
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl NetworkHandle {

/// Returns a sharable [`UnboundedReceiver<EngineMessage>`] that can be cloned and shared.
///
/// The Engine message is used to communicate between the network and the EngineTask.
/// The Engine message is used to communicate between the network and the `EngineTask`.
pub fn get_to_engine_rx(&self) -> Arc<Mutex<UnboundedReceiver<EngineMessage>>> {
self.inner.engine_rx.clone()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/node/builder/src/launch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ where

(pipeline, Either::Right(client))
}
#[cfg(all(not(feature = "bsc")))]
#[cfg(not(feature = "bsc"))]
{
let pipeline = crate::setup::build_networked_pipeline(
&ctx.toml_config().stages,
Expand Down

0 comments on commit 09b9cbb

Please sign in to comment.