Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[client cli] generic blocknumber #4376

Merged
merged 6 commits into from Dec 17, 2019
Merged

[client cli] generic blocknumber #4376

merged 6 commits into from Dec 17, 2019

Conversation

niklasad1
Copy link
Member

@niklasad1 niklasad1 commented Dec 12, 2019

Attempt to close #2653

It changes that block number is hardcoded to u32 instead it stores a String and parses it at runtime to appropriate type.

@parity-cla-bot
Copy link

It looks like @niklasad1 signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

pub fn parse<N>(&self) -> Result<N, String>
where
N: FromStr,
N::Err: std::fmt::Debug,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for printing the error which can be useful

///
/// See `https://doc.rust-lang.org/std/primitive.str.html#method.parse` for more elaborate
/// documentation.
pub fn parse<N>(&self) -> Result<N, String>
Copy link
Member Author

@niklasad1 niklasad1 Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing prevents parsing BlockNumber to a signed integer thus it relies on each type's FromStr` implementation.

If the value is bigger than 2^(n-1) it will be an Overflow for the types in core::num at least, where n is the number of bits of the integer.

@gavofyork gavofyork added the A0-please_review Pull request needs code review. label Dec 13, 2019
@bkchr bkchr merged commit f548309 into master Dec 17, 2019
@bkchr bkchr deleted the na-cli-generic-blocknumber branch December 17, 2019 10:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make BlockNumber in CLI generic as well
5 participants