Skip to content

Conversation

@hinto-janai
Copy link
Contributor

@hinto-janai hinto-janai commented Mar 25, 2025

What

Adds system {data,cache,config} directory info to ./cuprated --version.

cargo r --bin cuprated -- --version
{
  "major_version": 0,
  "minor_version": 0,
  "patch_version": 1,
  "rpc_major_version": 3,
  "rpc_minor_version": 14,
  "rpc_version": 196622,
  "hardfork": 16,
  "blockchain_db_version": 0,
  "semantic_version": "0.0.1",
  "build": "debug",
  "commit": "5a8089a4a3f2bdf73be99bfaf9e6410475e5395a",
  "killswitch_timestamp": 1744761600,
  "cache_directory": "/home/hinto/.cache/cuprate",
  "config_directory": "/home/hinto/.config/cuprate",
  "data_directory": "/home/hinto/.local/share/cuprate"
}

Why

Useful info for debugging / sanity checking / users.

@github-actions github-actions bot added the A-binaries Area: Related to binaries. label Mar 25, 2025
@hinto-janai hinto-janai marked this pull request as ready for review March 25, 2025 02:25
@hinto-janai hinto-janai added the C-feature Category: This is an issue/PR that adds a new feature. label Apr 1, 2025
@Boog900
Copy link
Member

Boog900 commented Apr 2, 2025

IMO this should take into account the config, currently it just using the default, right?

@hinto-janai
Copy link
Contributor Author

hinto-janai commented Apr 2, 2025

IMO this should take into account the config

That means this line:

args.do_quick_requests();

has to be after:

let config: Config = if let Some(config_file) = &args.config_file {

That means something like ./cuprated --help may not work depending on if config reading fails. Kind of a hacky workaround:

pub fn read_config_and_args() -> Config {
    let args = args::Args::parse();

    let config: Config = try_get_config().map(|c| args.apply_args(c));

    args.do_quick_requests(&config); // if Ok(config), use in `*_directory`, else ""

    match config {
        Ok(c) => c,
        Err(e) => {
            tracing::debug!("Failed to read config: {e}");
            if !args.skip_config_warning {
                eprintln_red(DEFAULT_CONFIG_WARNING);
                std::thread::sleep(DEFAULT_CONFIG_STARTUP_DELAY);
            }
        }
    }
}

currently it just using the default, right?

Yes, should the fields be renamed to *_default_directory? I agree that displaying the directories cuprated will actually use is helpful, as well as the defaults.

@Boog900
Copy link
Member

Boog900 commented Apr 3, 2025

Hmm, I don't really want to move that to after reading the config. I also don't know how useful just giving the default out is - it is just a constant.

the RPC exposes this right? isn't that enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-binaries Area: Related to binaries. C-feature Category: This is an issue/PR that adds a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants