Skip to content

Commit

Permalink
clippies
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Oct 16, 2024
1 parent 67376b5 commit 261275c
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 238 deletions.
52 changes: 0 additions & 52 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 @@ -7,7 +7,7 @@ edition = "2021"

[workspace]
members = [
"base_layer/chat_ffi",
# "base_layer/chat_ffi",
"base_layer/core",
"base_layer/common_types",
"base_layer/contacts",
Expand Down
6 changes: 3 additions & 3 deletions applications/minotari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tari_common_types = { path = "../../base_layer/common_types" }
tari_contacts = { path = "../../base_layer/contacts" }
tari_crypto = { version = "0.21.0" }
tari_key_manager = { path = "../../base_layer/key_manager" }
tari_libtor = { path = "../../infrastructure/libtor", optional = true }
#tari_libtor = { path = "../../infrastructure/libtor", optional = true }
tari_max_size = { path = "../../infrastructure/max_size" }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_script = { path = "../../infrastructure/tari_script" }
Expand Down Expand Up @@ -86,10 +86,10 @@ features = ["crossterm"]
tari_features = { path = "../../common/tari_features", version = "1.7.0-pre.0" }

[features]
default = ["libtor", "ledger"]
default = ["ledger"]
grpc = []
ledger = ["minotari_ledger_wallet_comms", "minotari_wallet/ledger"]
libtor = ["tari_libtor"]
#libtor = ["tari_libtor"]

[package.metadata.cargo-machete]
# We need to specify extra features for log4rs even though it is not used directly in this crate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ pub async fn command_runner(
println!("Command Runner");
println!("==============");

let (_current_index, mut peer_list) = wallet
let (_current_index, peer_list) = wallet
.wallet_connectivity
.get_base_node_peer_manager_state()
.unwrap_or_default();
Expand Down Expand Up @@ -1660,7 +1660,7 @@ pub async fn command_runner(
},
}

temp_ban_peers(&wallet, &mut peer_list).await;
temp_ban_peers(&wallet, &peer_list).await;
unban_peer_manager_peers = true;

// Read session info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -891,12 +891,12 @@ impl wallet_server::Wallet for WalletGrpcServer {
let mut base_node_service = self.wallet.base_node_service.clone();

let status = match conns.len() {
x if x == 0 => tari_rpc::ConnectivityStatus::Offline,
0 => tari_rpc::ConnectivityStatus::Offline,
_ => tari_rpc::ConnectivityStatus::Online,
};

let resp = tari_rpc::NetworkStatusResponse {
status: tari_rpc::ConnectivityStatus::from(status) as i32,
status: status as i32,
avg_latency_ms: base_node_service
.get_base_node_latency()
.await
Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_console_wallet/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ pub async fn start_wallet(
})?;
} else {
// Set the first base node connection we get - this is typically a local base node via mDNS
match wait_for_first_base_node_connection(&wallet).await? {
match wait_for_first_base_node_connection(wallet).await? {
Some(pk) => {
wallet
.set_base_node_peer(pk, None, Some(base_nodes.to_vec()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl NetworkTab {

self.previous_public_key_field = self.public_key_field.clone();
self.previous_address_field = self.address_field.clone();
let base_node_previous = app_state.get_previous_base_node().clone();
let base_node_previous = app_state.get_previous_base_node();
let public_key = base_node_previous.map(|p| public_key_to_string(p.public_key()));
let public_address = base_node_previous.map(display_address);
self.public_key_field = public_key.unwrap_or_default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl CommandContext {

if must_ban {
self.network
.ban_peer(peer_id.clone(), "UI manual ban".to_string(), Some(duration))
.ban_peer(peer_id, "UI manual ban".to_string(), Some(duration))
.await?;
println!("Peer was banned in base node.");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl CommandContext {
let mut liveness_events = self.liveness.get_event_stream();
let mut liveness = self.liveness.clone();
task::spawn(async move {
if let Err(e) = liveness.send_ping(dest_peer_id.clone()).await {
if let Err(e) = liveness.send_ping(dest_peer_id).await {
println!("🏓 Ping failed to send to {}: {}", dest_peer_id, e);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions applications/minotari_node/src/commands/status_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ impl StatusLine {
Default::default()
}

pub fn add<T: ToString>(&mut self, value: T) -> &mut Self {
self.add_field("", value)
}
// pub fn add<T: ToString>(&mut self, value: T) -> &mut Self {
// self.add_field("", value)
// }

pub fn add_field<T: ToString>(&mut self, name: &'static str, value: T) -> &mut Self {
self.fields.push((name, value.to_string()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,7 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer {
.map_err(|err| obscure_error_if_true(report_error_flag, Status::internal(err.to_string())))?;

let status = match conns.len() {
x if x == 0 => tari_rpc::ConnectivityStatus::Offline,
0 => tari_rpc::ConnectivityStatus::Offline,
_ => tari_rpc::ConnectivityStatus::Online,
};

Expand Down
6 changes: 3 additions & 3 deletions applications/minotari_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ fn main_inner() -> Result<(), ExitError> {
console_subscriber::init();
}

#[cfg(all(unix, feature = "libtor"))]
let mut config = ApplicationConfig::load_from(&cfg)?;
#[cfg(not(all(unix, feature = "libtor")))]
// #[cfg(all(unix, feature = "libtor"))]
// let mut config = ApplicationConfig::load_from(&cfg)?;
// #[cfg(not(all(unix, feature = "libtor")))]
let config = ApplicationConfig::load_from(&cfg)?;
debug!(target: LOG_TARGET, "Using base node configuration: {:?}", config);

Expand Down
2 changes: 1 addition & 1 deletion applications/minotari_node/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Table<'t, 's> {
is_row_count_enabled: bool,
}

impl<'t, 's> Table<'t, 's> {
impl<'t> Table<'t, '_> {
pub fn new() -> Self {
Self {
titles: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ fn kernel_metadata() {
let r = PublicKey::from_hex("5c6bfaceaa1c83fa4482a816b5f82ca3975cb9b61b6e8be4ee8f01c5f1bee561").unwrap();
let sig = Signature::new(r, s);
let excess = Commitment::from_hex("e0bd3f743b566272277c357075b0584fc840d79efac49e9b3b6dbaa8a351bc0c").unwrap();
#[allow(unused_variables)]
let k = KernelBuilder::new()
.with_signature(sig)
.with_fee(100.into())
Expand Down
20 changes: 9 additions & 11 deletions base_layer/mmr/src/merkle_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,15 @@ impl MerkleProof {

impl Display for MerkleProof {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.write_str(&format!("MMR Size: {}\n", self.mmr_size))?;
f.write_str("Siblings:\n")?;
self.path
.iter()
.enumerate()
.fold(Ok(()), |_, (i, h)| f.write_str(&format!("{:3}: {}\n", i, h.to_hex())))?;
f.write_str("Peaks:\n")?;
self.peaks
.iter()
.enumerate()
.fold(Ok(()), |_, (i, h)| f.write_str(&format!("{:3}: {}\n", i, h.to_hex())))?;
writeln!(f, "MMR size: {}", self.mmr_size)?;
writeln!(f, "Siblings:")?;
for (i, h) in self.path.iter().enumerate() {
writeln!(f, "{:3}: {}", i, h.to_hex())?;
}
writeln!(f, "Peaks:")?;
for (i, h) in self.peaks.iter().enumerate() {
writeln!(f, "{:3}: {}", i, h.to_hex())?;
}
Ok(())
}
}
34 changes: 17 additions & 17 deletions base_layer/wallet/tests/support/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,20 @@ pub async fn make_input_with_features<R: Rng + CryptoRng>(
.unwrap()
}

/// This macro unlocks a Mutex or RwLock. If the lock is
/// poisoned (i.e. panic while unlocked) the last value
/// before the panic is used.
macro_rules! acquire_lock {
($e:expr, $m:ident) => {
match $e.$m() {
Ok(lock) => lock,
Err(poisoned) => {
log::warn!(target: "wallet", "Lock has been POISONED and will be silently recovered");
poisoned.into_inner()
},
}
};
($e:expr) => {
acquire_lock!($e, lock)
};
}
// /// This macro unlocks a Mutex or RwLock. If the lock is
// /// poisoned (i.e. panic while unlocked) the last value
// /// before the panic is used.
// macro_rules! acquire_lock {
// ($e:expr, $m:ident) => {
// match $e.$m() {
// Ok(lock) => lock,
// Err(poisoned) => {
// log::warn!(target: "wallet", "Lock has been POISONED and will be silently recovered");
// poisoned.into_inner()
// },
// }
// };
// ($e:expr) => {
// acquire_lock!($e, lock)
// };
// }
2 changes: 1 addition & 1 deletion base_layer/wallet_ffi/src/ffi_basenode_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ mod tests {
let original_best_block = BlockHash::zero();

let boxed_state = Box::into_raw(Box::new(TariBaseNodeState {
node_id: Some(original_node_id.clone()),
node_id: Some(original_node_id),
best_block_height: 123,
best_block_hash: original_best_block,
best_block_timestamp: 12345,
Expand Down
Loading

0 comments on commit 261275c

Please sign in to comment.