From 898548a01d9e3ff212ba648dd03ea11923f9ce62 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sun, 5 Jan 2025 02:15:07 +0000 Subject: [PATCH] fix fmt & clippy --- Cargo.lock | 106 ++++++++++++++++++++---- binaries/cuprated/src/config/fs.rs | 2 +- binaries/cuprated/src/config/storage.rs | 8 +- binaries/cuprated/src/logging.rs | 1 + binaries/cuprated/src/main.rs | 7 +- storage/blockchain/src/service/free.rs | 6 +- storage/txpool/src/service/free.rs | 3 +- 7 files changed, 104 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fda0fce4..4cef15c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -445,6 +445,7 @@ checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstyle", "clap_lex", + "strsim", "terminal_size", ] @@ -1234,6 +1235,7 @@ dependencies = [ "toml", "tower 0.5.1", "tracing", + "tracing-appender", "tracing-subscriber", ] @@ -1269,7 +1271,7 @@ dependencies = [ [[package]] name = "dalek-ff-group" version = "0.4.1" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "crypto-bigint", "curve25519-dalek", @@ -1296,6 +1298,15 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "diff" version = "0.1.13" @@ -1425,7 +1436,7 @@ dependencies = [ [[package]] name = "flexible-transcript" version = "0.3.2" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "blake2", "digest", @@ -2175,7 +2186,7 @@ dependencies = [ [[package]] name = "monero-address" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "curve25519-dalek", "monero-io", @@ -2188,7 +2199,7 @@ dependencies = [ [[package]] name = "monero-borromean" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "curve25519-dalek", "monero-generators", @@ -2201,7 +2212,7 @@ dependencies = [ [[package]] name = "monero-bulletproofs" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "curve25519-dalek", "monero-generators", @@ -2216,7 +2227,7 @@ dependencies = [ [[package]] name = "monero-clsag" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "curve25519-dalek", "dalek-ff-group", @@ -2236,7 +2247,7 @@ dependencies = [ [[package]] name = "monero-generators" version = "0.4.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "curve25519-dalek", "dalek-ff-group", @@ -2250,7 +2261,7 @@ dependencies = [ [[package]] name = "monero-io" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "curve25519-dalek", "std-shims", @@ -2259,7 +2270,7 @@ dependencies = [ [[package]] name = "monero-mlsag" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "curve25519-dalek", "monero-generators", @@ -2273,7 +2284,7 @@ dependencies = [ [[package]] name = "monero-primitives" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "curve25519-dalek", "monero-generators", @@ -2286,9 +2297,8 @@ dependencies = [ [[package]] name = "monero-rpc" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ - "async-trait", "curve25519-dalek", "hex", "monero-address", @@ -2303,7 +2313,7 @@ dependencies = [ [[package]] name = "monero-serai" version = "0.1.4-alpha" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "curve25519-dalek", "hex-literal", @@ -2321,9 +2331,8 @@ dependencies = [ [[package]] name = "monero-simple-request-rpc" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ - "async-trait", "digest_auth", "hex", "monero-rpc", @@ -2341,6 +2350,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" version = "0.2.19" @@ -2537,6 +2552,12 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -3088,7 +3109,7 @@ dependencies = [ [[package]] name = "simple-request" version = "0.1.0" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "http-body-util", "hyper", @@ -3154,12 +3175,18 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "std-shims" version = "0.1.1" -source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79" +source = "git+https://github.com/Cuprate/serai.git?rev=e6fdef6#e6fdef6d0b4481932ac9647796eb3fa56197ed66" dependencies = [ "hashbrown 0.14.5", "spin", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "strum" version = "0.26.3" @@ -3296,6 +3323,37 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a693d0c8cf16973fac5a93fbe47b8c6452e7097d4fcac49f3d7a18e39c76e62e" +[[package]] +name = "time" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tinystr" version = "0.7.6" @@ -3389,6 +3447,8 @@ dependencies = [ "bytes", "futures-core", "futures-sink", + "futures-util", + "hashbrown 0.14.5", "pin-project-lite", "slab", "tokio", @@ -3495,6 +3555,18 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror", + "time", + "tracing-subscriber", +] + [[package]] name = "tracing-attributes" version = "0.1.28" diff --git a/binaries/cuprated/src/config/fs.rs b/binaries/cuprated/src/config/fs.rs index 96057129..85e70f46 100644 --- a/binaries/cuprated/src/config/fs.rs +++ b/binaries/cuprated/src/config/fs.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use cuprate_helper::fs::{CUPRATE_CACHE_DIR, CUPRATE_DATA_DIR}; -#[derive(Debug, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields, default)] pub struct FileSystemConfig { pub data_directory: PathBuf, diff --git a/binaries/cuprated/src/config/storage.rs b/binaries/cuprated/src/config/storage.rs index 4914b6e1..989ace11 100644 --- a/binaries/cuprated/src/config/storage.rs +++ b/binaries/cuprated/src/config/storage.rs @@ -7,7 +7,7 @@ use cuprate_database_service::ReaderThreads; use cuprate_helper::fs::CUPRATE_DATA_DIR; /// The storage config. -#[derive(Debug, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields, default)] pub struct StorageConfig { /// The amount of reader threads to spawn between the tx-pool and blockchain. @@ -33,7 +33,7 @@ impl Default for StorageConfig { } /// The blockchain config. -#[derive(Debug, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields, default)] pub struct BlockchainConfig { #[serde(flatten)] @@ -51,7 +51,7 @@ impl Default for BlockchainConfig { } /// The tx-pool config. -#[derive(Debug, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields, default)] pub struct TxpoolConfig { #[serde(flatten)] @@ -73,7 +73,7 @@ impl Default for TxpoolConfig { } /// Config values shared between the tx-pool and blockchain. -#[derive(Debug, Default, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Default, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields, default)] pub struct SharedStorageConfig { /// The [`SyncMode`] of the database. diff --git a/binaries/cuprated/src/logging.rs b/binaries/cuprated/src/logging.rs index e6d72b8d..0d87a879 100644 --- a/binaries/cuprated/src/logging.rs +++ b/binaries/cuprated/src/logging.rs @@ -34,6 +34,7 @@ static FILE_WRITER_FILTER_HANDLE: OnceLock tokio::runtime::Runtime { fn init_global_rayon_pool(config: &Config) { rayon::ThreadPoolBuilder::new() .num_threads(config.rayon.threads) - .thread_name(|index| format!("cuprated-rayon-{}", index)) + .thread_name(|index| format!("cuprated-rayon-{index}")) .build_global() - .unwrap() + .unwrap(); } /// The [`Command`] handler loop. diff --git a/storage/blockchain/src/service/free.rs b/storage/blockchain/src/service/free.rs index 20a72527..d09e7440 100644 --- a/storage/blockchain/src/service/free.rs +++ b/storage/blockchain/src/service/free.rs @@ -1,10 +1,12 @@ //! General free functions used (related to `cuprate_blockchain::service`). //---------------------------------------------------------------------------------------------------- Import +use std::sync::Arc; + +use rayon::ThreadPool; + use cuprate_database::{ConcreteEnv, InitError}; use cuprate_types::{AltBlockInformation, VerifiedBlockInformation}; -use rayon::ThreadPool; -use std::sync::Arc; use crate::{ config::Config, diff --git a/storage/txpool/src/service/free.rs b/storage/txpool/src/service/free.rs index 0971125e..bf6fb9bd 100644 --- a/storage/txpool/src/service/free.rs +++ b/storage/txpool/src/service/free.rs @@ -4,10 +4,9 @@ use rayon::ThreadPool; use cuprate_database::{ConcreteEnv, InitError}; -use crate::service::read::init_read_service_with_pool; use crate::{ service::{ - read::init_read_service, + read::{init_read_service, init_read_service_with_pool}, types::{TxpoolReadHandle, TxpoolWriteHandle}, write::init_write_service, },