diff --git a/binaries/cuprated/Cuprated.toml b/binaries/cuprated/Cuprated.toml index a0446251..d248ce1f 100644 --- a/binaries/cuprated/Cuprated.toml +++ b/binaries/cuprated/Cuprated.toml @@ -41,11 +41,11 @@ peer_save_period = { secs = 90, nanos = 0 } ## The block downloader config. [p2p.block_downloader] ## The size of the buffer of sequential blocks waiting to be verified and added to the chain (bytes). -buffer_size = 50_000_000 +buffer_bytes = 50_000_000 ## The size of the queue of blocks which are waiting for a parent block to be downloaded (bytes). -in_progress_queue_size = 50_000_000 +in_progress_queue_bytes = 50_000_000 ## The target size of a batch of blocks (bytes), must not exceed 100MB. -target_batch_size = 5_000_000 +target_batch_bytes= 5_000_000 ## The amount of time between checking the pool of connected peers for free peers to download blocks. check_client_pool_interval = { secs = 30, nanos = 0 } diff --git a/binaries/cuprated/src/config.rs b/binaries/cuprated/src/config.rs index 53a9c6dd..c6267a69 100644 --- a/binaries/cuprated/src/config.rs +++ b/binaries/cuprated/src/config.rs @@ -31,13 +31,14 @@ use tracing_config::TracingConfig; /// Reads the args & config file, returning a [`Config`]. pub fn read_config_and_args() -> Config { let args = args::Args::parse(); + args.do_quick_requests(); let config: Config = if let Some(config_file) = &args.config_file { // If a config file was set in the args try to read it and exit if we can't. match Config::read_from_path(config_file) { Ok(config) => config, Err(e) => { - tracing::error!("Failed to read config from file: {e}"); + eprintln!("Failed to read config from file: {e}"); std::process::exit(1); } } @@ -55,7 +56,7 @@ pub fn read_config_and_args() -> Config { }) .inspect_err(|e| { tracing::debug!("Failed to read config from config dir: {e}"); - println!("Failed to find/read config file, using default config."); + eprintln!("Failed to find/read config file, using default config."); }) .unwrap_or_default() }; @@ -92,10 +93,10 @@ impl Config { let file_text = read_to_string(file.as_ref())?; Ok(toml::from_str(&file_text) - .inspect(|_| println!("Using config at: {}", file.as_ref().to_string_lossy())) + .inspect(|_| eprintln!("Using config at: {}", file.as_ref().to_string_lossy())) .inspect_err(|e| { - println!("{e}"); - println!( + eprintln!("{e}"); + eprintln!( "Failed to parse config file at: {}", file.as_ref().to_string_lossy() ); diff --git a/binaries/cuprated/src/config/args.rs b/binaries/cuprated/src/config/args.rs index 650c8a45..3930ce57 100644 --- a/binaries/cuprated/src/config/args.rs +++ b/binaries/cuprated/src/config/args.rs @@ -24,21 +24,26 @@ pub struct Args { /// The PATH of the `cuprated` config file. #[arg(long)] pub config_file: Option, - /// Generate a config file and place it in the given PATH. + /// Generate a config file and print it to stdout. #[arg(long)] - pub generate_config: Option, + pub generate_config: bool, } impl Args { + /// Complete any quick requests asked for in [`Args`]. + /// + /// May cause the process to [`exit`]. + pub fn do_quick_requests(&self) { + if self.generate_config { + println!("{EXAMPLE_CONFIG}"); + exit(0); + }; + } + /// Apply the [`Args`] to the given [`Config`]. /// /// This may exit the program if a config value was set that requires an early exit. pub fn apply_args(&self, mut config: Config) -> Config { - if let Some(config_folder) = self.generate_config.as_ref() { - println!("{EXAMPLE_CONFIG}"); - exit(0); - }; - config.network = self.network; if let Some(outbound_connections) = self.outbound_connections { diff --git a/storage/database/src/backend/redb/storable.rs b/storage/database/src/backend/redb/storable.rs index abf2e71b..f0412efb 100644 --- a/storage/database/src/backend/redb/storable.rs +++ b/storage/database/src/backend/redb/storable.rs @@ -34,8 +34,14 @@ impl redb::Value for StorableRedb where T: Storable + 'static, { - type SelfType<'a> = T where Self: 'a; - type AsBytes<'a> = &'a [u8] where Self: 'a; + type SelfType<'a> + = T + where + Self: 'a; + type AsBytes<'a> + = &'a [u8] + where + Self: 'a; #[inline] fn fixed_width() -> Option {