Skip to content

Commit

Permalink
chore: rustc 1.78.0 (#4167)
Browse files Browse the repository at this point in the history
* rustc 1.76.0

* rustc 1.78.0

* fix clippy

* fix clippy

* fix clippy

* fix clippy!

* fix clippy!!

* fix fmt

* fix fmt

* fix fmt

* fix clippy!!!

* restrict clippy checking

---------

Co-authored-by: simonjiao <[email protected]>
  • Loading branch information
nkysg and simonjiao authored Aug 5, 2024
1 parent ddaf1a3 commit 9b4670a
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 141 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ rpassword = "~5"
rust-argon2 = "0.8"
rust-embed = "6.3.0"
rust-flatten-json = "0.2.0"
rustc-serialize = "^0.3"
rustc-serialize = "0.3.25"
rustyline = "9.1.2"
rustyline-derive = "0.6.0"
sc-peerset = { path = "network-p2p/peerset" }
Expand Down
2 changes: 1 addition & 1 deletion cmd/indexer/src/es_sinker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl EsSinker {
self.create_index_if_not_exists(txn_event_index).await?;
self.create_index_if_not_exists(pending_txn_index).await?;
let tip = self.get_remote_tip_header().await?;
self.state.write().await.tip = tip.clone();
self.state.write().await.tip.clone_from(&tip);
if let Some(tip_info) = tip {
info!(
"remote tips: {}, {}",
Expand Down
2 changes: 1 addition & 1 deletion commons/forkable-jellyfish-merkle/src/nibble_path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl<'a> NibbleIterator<'a> {

/// Advance both iterators if their next nibbles are the same until either reaches the end or
/// the find a mismatch. Return the number of matched nibbles.
pub fn skip_common_prefix<'a, 'b, I1: 'a, I2: 'b>(x: &'a mut I1, y: &mut I2) -> usize
pub fn skip_common_prefix<I1, I2>(x: &mut I1, y: &mut I2) -> usize
where
I1: Iterator + Peekable,
I2: Iterator + Peekable,
Expand Down
4 changes: 2 additions & 2 deletions commons/service-registry/src/bus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ pub trait Bus {
where
M: Send + Clone + Debug + 'static;

fn broadcast<M: 'static>(&self, msg: M) -> Result<(), TrySendError<M>>
fn broadcast<M>(&self, msg: M) -> Result<(), TrySendError<M>>
where
M: Send + Clone + Debug;
M: Send + Clone + Debug + 'static;
}

#[async_trait::async_trait]
Expand Down
1 change: 1 addition & 0 deletions commons/service-registry/src/handler_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ where
self.start(ctx)
}
fn status(&self) -> ServiceStatus;
#[allow(dead_code)]
fn as_any(&self) -> &dyn Any;
fn as_mut_any(&mut self) -> &mut dyn Any;
}
Expand Down
6 changes: 4 additions & 2 deletions config/src/account_provider_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ impl ConfigModule for AccountProviderConfig {
bail!("Account provider conflicts")
};
if opt.account_provider.account_dir.is_some() {
self.account_dir = opt.account_provider.account_dir.clone()
self.account_dir
.clone_from(&opt.account_provider.account_dir);
}
if opt.account_provider.secret_file.is_some() {
self.secret_file = opt.account_provider.secret_file.clone();
self.secret_file
.clone_from(&opt.account_provider.secret_file);
self.account_address = opt.account_provider.account_address;
}
self.from_env = opt.account_provider.from_env;
Expand Down
2 changes: 1 addition & 1 deletion config/src/account_vault_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl ConfigModule for AccountVaultConfig {
fn merge_with_opt(&mut self, opt: &StarcoinOpt, base: Arc<BaseConfig>) -> Result<()> {
self.base = Some(base);
if opt.vault.dir.is_some() {
self.dir = opt.vault.dir.clone();
self.dir.clone_from(&opt.vault.dir);
}
Ok(())
}
Expand Down
20 changes: 12 additions & 8 deletions config/src/network_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,21 @@ impl NetworkRpcQuotaConfiguration {

pub fn merge(&mut self, o: &Self) -> Result<()> {
if o.default_global_api_quota.is_some() {
self.default_global_api_quota = o.default_global_api_quota.clone();
self.default_global_api_quota
.clone_from(&o.default_global_api_quota);
}
//TODO should merge two vec?
if o.custom_global_api_quota.is_some() {
self.custom_global_api_quota = o.custom_global_api_quota.clone();
self.custom_global_api_quota
.clone_from(&o.custom_global_api_quota);
}
if o.default_user_api_quota.is_some() {
self.default_user_api_quota = o.default_user_api_quota.clone();
self.default_user_api_quota
.clone_from(&o.default_user_api_quota);
}
if o.custom_user_api_quota.is_some() {
self.custom_user_api_quota = o.custom_user_api_quota.clone();
self.custom_user_api_quota
.clone_from(&o.custom_user_api_quota);
}
Ok(())
}
Expand Down Expand Up @@ -359,7 +363,7 @@ impl NetworkConfig {

fn generate_listen_address(&mut self) {
if self.listen.is_some() {
self.generate_listen = self.listen.clone();
self.generate_listen.clone_from(&self.listen);
} else {
let base = self.base();
let port = if base.net().is_test() || base.net().is_dag_test() {
Expand Down Expand Up @@ -411,19 +415,19 @@ impl ConfigModule for NetworkConfig {
.merge(&opt.network.network_rpc_quotas)?;

if opt.network.node_name.is_some() {
self.node_name = opt.network.node_name.clone();
self.node_name.clone_from(&opt.network.node_name);
}

if self.node_name.is_none() {
self.node_name = Some(generate_node_name())
}

if opt.network.node_key.is_some() {
self.node_key = opt.network.node_key.clone();
self.node_key.clone_from(&opt.network.node_key);
}

if opt.network.listen.is_some() {
self.listen = opt.network.listen.clone();
self.listen.clone_from(&opt.network.listen);
}
if let Some(m) = opt.network.max_peers_to_propagate {
self.max_peers_to_propagate = Some(m);
Expand Down
20 changes: 12 additions & 8 deletions config/src/rpc_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl HttpConfiguration {
self.disable = true;
}
if o.apis.is_some() {
self.apis = o.apis.clone();
self.apis.clone_from(&o.apis);
}
if o.port.is_some() {
self.port = o.port;
Expand Down Expand Up @@ -160,7 +160,7 @@ impl TcpConfiguration {
self.disable = true;
}
if o.apis.is_some() {
self.apis = o.apis.clone();
self.apis.clone_from(&o.apis);
}
if o.port.is_some() {
self.port = o.port;
Expand Down Expand Up @@ -207,7 +207,7 @@ impl WsConfiguration {
self.disable = true;
}
if o.apis.is_some() {
self.apis = o.apis.clone();
self.apis.clone_from(&o.apis);
}
if o.port.is_some() {
self.port = o.port;
Expand Down Expand Up @@ -239,7 +239,7 @@ impl IpcConfiguration {
self.disable = true;
}
if o.apis.is_some() {
self.apis = o.apis.clone();
self.apis.clone_from(&o.apis);
}
Ok(())
}
Expand Down Expand Up @@ -315,17 +315,21 @@ impl ApiQuotaConfiguration {

pub fn merge(&mut self, o: &Self) -> Result<()> {
if o.default_global_api_quota.is_some() {
self.default_global_api_quota = o.default_global_api_quota.clone();
self.default_global_api_quota
.clone_from(&o.default_global_api_quota);
}
//TODO should merge two vec?
if o.custom_global_api_quota.is_some() {
self.custom_global_api_quota = o.custom_global_api_quota.clone();
self.custom_global_api_quota
.clone_from(&o.custom_global_api_quota);
}
if o.default_user_api_quota.is_some() {
self.default_user_api_quota = o.default_user_api_quota.clone();
self.default_user_api_quota
.clone_from(&o.default_user_api_quota);
}
if o.custom_user_api_quota.is_some() {
self.custom_user_api_quota = o.custom_user_api_quota.clone();
self.custom_user_api_quota
.clone_from(&o.custom_user_api_quota);
}
Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions flexidag/src/reachability/inquirer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ pub(super) fn get_next_chain_ancestor_unchecked(

enum SearchOutput {
NotFound(usize), // `usize` is the position to insert at
#[allow(dead_code)]
Found(Hash, usize),
}

Expand Down
7 changes: 0 additions & 7 deletions miner/src/create_block_template/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ mod metrics;
//#[cfg(test)]
//mod test_create_block_template;

#[derive(Debug)]
pub struct GetHeadRequest;

impl ServiceRequest for GetHeadRequest {
type Response = HashValue;
}

#[derive(Debug)]
pub struct BlockTemplateRequest;

Expand Down
11 changes: 0 additions & 11 deletions network-p2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

extern crate prometheus;
#[macro_use]
extern crate starcoin_metrics;

pub use crate::protocol::event::{DhtEvent, Event};
Expand Down Expand Up @@ -43,13 +42,3 @@ mod utils;
const MAX_CONNECTIONS_PER_PEER: usize = 2;
/// The maximum number of concurrent established connections that were incoming.
const MAX_CONNECTIONS_ESTABLISHED_INCOMING: u32 = 10_000;

trait DiscoveryNetBehaviour {
/// Notify the protocol that we have learned about the existence of nodes.
///
/// Can (or most likely will) be called multiple times with the same `PeerId`s.
///
/// Also note that there is no notification for expired nodes. The implementer must add a TTL
/// system, or remove nodes that will fail to reach.
fn add_discovered_nodes(&mut self, nodes: impl Iterator<Item = PeerId>);
}
15 changes: 2 additions & 13 deletions network-p2p/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use crate::protocol::generic_proto::{GenericProto, GenericProtoOut, Notification
// use crate::protocol::message::generic::Status;
use crate::business_layer_handle::BusinessLayerHandle;
use crate::utils::interval;
use crate::{errors, DiscoveryNetBehaviour, Multiaddr};
use crate::{errors, Multiaddr};
use bytes::Bytes;
use futures::prelude::*;
use libp2p::core::connection::ConnectionId;
use libp2p::swarm::behaviour::FromSwarm;
use libp2p::swarm::{ConnectionHandler, IntoConnectionHandler};
use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p::PeerId;
use log::Level;
use log::{debug, error, log, trace, warn, Level};
use sc_peerset::{peersstate::PeersState, SetId};
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -311,17 +311,6 @@ impl<T: BusinessLayerHandle + Send> NetworkBehaviour for Protocol<T> {
}
}

impl<T: BusinessLayerHandle + Send> DiscoveryNetBehaviour for Protocol<T> {
fn add_discovered_nodes(&mut self, peer_ids: impl Iterator<Item = PeerId>) {
for peer_id in peer_ids {
for (set_id, _) in self.notif_protocols.iter().enumerate() {
self.peerset_handle
.add_to_peers_set(SetId::from(set_id), peer_id);
}
}
}
}

impl<T: 'static + BusinessLayerHandle + Send> Protocol<T> {
/// Create a new instance.
pub fn new(
Expand Down
2 changes: 1 addition & 1 deletion network-p2p/src/protocol/generic_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
pub use self::behaviour::{GenericProto, GenericProtoOut};
pub use self::handler::{NotificationsSink, NotifsHandlerError, Ready};
#[allow(clippy::blocks_in_if_conditions)]
#[allow(clippy::blocks_in_conditions)]
mod behaviour;
mod handler;
mod tests;
Expand Down
1 change: 1 addition & 0 deletions network-p2p/src/request_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ use libp2p::{
handler::multi::MultiHandler, NetworkBehaviour, NetworkBehaviourAction, PollParameters,
},
};
use log::info;
pub use network_p2p_types::{
IfDisconnected, InboundFailure, IncomingRequest, OutboundFailure, OutgoingResponse,
RequestFailure, ResponseFailure,
Expand Down
33 changes: 1 addition & 32 deletions network-p2p/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ use libp2p::{
},
PeerId,
};
use log::{error, info, trace, warn};
use log::{debug, error, info, trace, warn};
use network_p2p_types::IfDisconnected;
use parking_lot::Mutex;
use sc_peerset::{peersstate, PeersetHandle, ReputationChange};
Expand All @@ -79,12 +79,6 @@ use std::num::NonZeroUsize;
use std::time::Duration;
const REQUEST_RESPONSE_TIMEOUT_SECONDS: u64 = 60 * 5;

/// Minimum Requirements for a Hash within Networking
pub trait ExHashT: std::hash::Hash + Eq + std::fmt::Debug + Clone + Send + Sync + 'static {}

impl<T> ExHashT for T where T: std::hash::Hash + Eq + std::fmt::Debug + Clone + Send + Sync + 'static
{}

/// A cloneable handle for reporting cost/benefits of peers.
#[derive(Clone)]
pub struct ReportHandle {
Expand All @@ -104,8 +98,6 @@ impl From<PeersetHandle> for ReportHandle {
pub struct NetworkService {
/// Number of peers we're connected to.
num_connected: Arc<AtomicUsize>,
/// The local external addresses.
external_addresses: Arc<Mutex<Vec<Multiaddr>>>,
/// Are we actively catching up with the chain?
is_major_syncing: Arc<AtomicBool>,
/// Local copy of the `PeerId` of the local node.
Expand Down Expand Up @@ -324,7 +316,6 @@ impl<T: BusinessLayerHandle + Send> NetworkWorker<T> {
Swarm::add_external_address(&mut swarm, addr.clone(), AddressScore::Infinite);
}

let external_addresses = Arc::new(Mutex::new(Vec::new()));
let peers_notifications_sinks = Arc::new(Mutex::new(HashMap::new()));

let metrics = params
Expand All @@ -333,7 +324,6 @@ impl<T: BusinessLayerHandle + Send> NetworkWorker<T> {
.and_then(|registry| Metrics::register(registry).ok());
let service = Arc::new(NetworkService {
bandwidth,
external_addresses,
num_connected,
is_major_syncing,
peerset: peerset_handle,
Expand Down Expand Up @@ -885,27 +875,6 @@ impl NetworkService {
}
}

/// Trait for providing information about the local network state
pub trait NetworkStateInfo {
/// Returns the local external addresses.
fn external_addresses(&self) -> Vec<Multiaddr>;

/// Returns the local Peer ID.
fn local_peer_id(&self) -> PeerId;
}

impl NetworkStateInfo for NetworkService {
/// Returns the local external addresses.
fn external_addresses(&self) -> Vec<Multiaddr> {
self.external_addresses.lock().clone()
}

/// Returns the local Peer ID.
fn local_peer_id(&self) -> PeerId {
self.local_peer_id
}
}

/// A `NotificationSender` allows for sending notifications to a peer with a chosen protocol.
#[must_use]
pub struct NotificationSender {
Expand Down
Loading

0 comments on commit 9b4670a

Please sign in to comment.