Skip to content

Implement human-readable bytes in the config #4295

@0x009922

Description

@0x009922

Description

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

https://github.com/hyperledger/iroha/blob/964476722e2a219becaacdb3676ca058ec5748cd/config/base/src/lib.rs#L36-L38

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or requestUISomething about the interfaceconfig-changesChanges in configuration and start up of the Irohagood first issueGood for newcomersiroha2-devThe re-implementation of a BFT hyperledger in RUSTquestionFurther information is requested

    Type

    No type

    Projects

    Status

    Roadmap

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions