Fixed multiple clippy warnings.

This commit is contained in:
Revertron
2021-12-25 18:40:36 +01:00
parent d776cca5b3
commit 797584c516
29 changed files with 313 additions and 360 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ pub const BLOCK_SIGNERS_MIN: u64 = 4;
pub const LIMITED_CONFIDENCE_DEPTH: u64 = 4;
/// We start mining signing blocks after random delay, this is the max delay
pub const BLOCK_SIGNERS_START_RANDOM: i64 = 180;
pub const BLOCK_SIGNERS_START_RANDOM: i64 = 90;
pub const NEW_DOMAINS_INTERVAL: i64 = 86400; // One day in seconds
pub const DOMAIN_LIFETIME: i64 = 86400 * 365; // One year
+5 -7
View File
@@ -22,7 +22,7 @@ pub fn to_hex(buf: &[u8]) -> String {
}
pub fn from_hex(string: &str) -> Result<Vec<u8>, num::ParseIntError> {
split_n(&string.trim()[..], 2)
split_n(string.trim(), 2)
.iter()
.map(|b| u8::from_str_radix(b, 16))
.collect()
@@ -32,11 +32,9 @@ pub fn check_domain(name: &str, allow_dots: bool) -> bool {
if name.starts_with('.') || name.starts_with('-') || name.ends_with('.') || name.ends_with('-') {
return false;
}
let parts: Vec<&str> = name.rsplitn(2, ".").collect();
if parts.len() == 2 {
if parts[1].len() < 3 && is_numeric(parts[1]) {
return false;
}
let parts: Vec<&str> = name.rsplitn(2, '.').collect();
if parts.len() == 2 && parts[1].len() < 3 && is_numeric(parts[1]) {
return false;
}
let mut last_dot = false;
@@ -77,7 +75,7 @@ pub fn is_numeric(str: &str) -> bool {
}
pub fn get_domain_zone(domain: &str) -> String {
let parts: Vec<&str> = domain.rsplitn(2, ".").collect();
let parts: Vec<&str> = domain.rsplitn(2, '.').collect();
if !parts.is_empty() {
parts[0].to_owned()
} else {
+4 -2
View File
@@ -2,7 +2,9 @@ use std::collections::HashMap;
use uuid::Uuid;
#[derive(Default)]
pub struct Bus<T> {
#[allow(clippy::type_complexity)]
listeners: HashMap<Uuid, Box<dyn FnMut(&Uuid, T) -> bool + Send + Sync>>
}
@@ -13,12 +15,12 @@ impl<T: Clone> Bus<T> {
pub fn register<F>(&mut self, closure: F) -> Uuid where F: FnMut(&Uuid, T) -> bool + Send + Sync + 'static {
let uuid = Uuid::new_v4();
self.listeners.insert(uuid.clone(), Box::new(closure));
self.listeners.insert(uuid, Box::new(closure));
uuid
}
pub fn unregister(&mut self, uuid: &Uuid) {
self.listeners.remove(&uuid);
self.listeners.remove(uuid);
}
pub fn post(&mut self, event: T) {