Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement human-readable bytes in the config #4295

Open
0x009922 opened this issue Feb 18, 2024 · 2 comments
Open

Implement human-readable bytes in the config #4295

0x009922 opened this issue Feb 18, 2024 · 2 comments
Labels
config-changes Changes in configuration and start up of the Iroha Enhancement New feature or request good first issue Good for newcomers iroha2-dev The re-implementation of a BFT hyperledger in RUST question Further information is requested UI Something about the interface

Comments

@0x009922
Copy link
Contributor

Description

Actually implement parsing from a human-readable string for HumanBytes:

/// Representation of amount of bytes, parseable from a human-readable string.
#[derive(Debug, Copy, Clone, Deserialize, Serialize)]
pub struct HumanBytes<T: num_traits::int::PrimInt>(pub T);

Specification

Here is an excerpt from the config reference draft:

Bytes amount is specified as a human-readable string:

# 42 bytes
value1 = "42B"

# 1 kilobyte = 1000 bytes
value2 = "1KB"

# 1 kilobyte (binary format) = 1024 bytes
value3 = "1KiB"

# Sum of multiple
value4 = "1GB 5MB"

Iroha can parse sizes in bytes, kilobytes (K), megabytes (M), gigabytes (G), terabytes (T),
and petabytes (P).

The format of suffixes:

  • {size}iB: Binary size
  • {size}B: Decimal size

I used humanfriendly Python package as a reference.

Also

@0x009922 0x009922 added Enhancement New feature or request good first issue Good for newcomers iroha2-dev The re-implementation of a BFT hyperledger in RUST config-changes Changes in configuration and start up of the Iroha UI Something about the interface labels Feb 18, 2024
@mversic mversic added the question Further information is requested label Feb 19, 2024
@mversic
Copy link
Contributor

mversic commented Feb 19, 2024

as discussed hyperledger/iroha-2-docs#392 I'm not sure we want to complicate config files. Simple fixed suffix on the field name should suffice IMO. We need to discuss this before proceeding

@DCNick3
Copy link
Contributor

DCNick3 commented Jul 26, 2024

I am in favor of having human-readable suffixes in config, this makes it much easier to write large values by hand.

Oftentimes, when a large value is needed, you would still end up having a comment to explain what the value actually is, like max_transfer_bytes = 1048576 # 1 MiB, so having this natively supported by the config system is better UX IMO.

Same opinion on the #4294 with the same arguments, time_value = "1h" is better than time_value_ms = 3600000 # 1 hour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config-changes Changes in configuration and start up of the Iroha Enhancement New feature or request good first issue Good for newcomers iroha2-dev The re-implementation of a BFT hyperledger in RUST question Further information is requested UI Something about the interface
Projects
Status: Roadmap
Development

No branches or pull requests

3 participants