You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve ChainId implementation; this is API breaking change
ChainId::new allocates a new String so there’s no point in passing
ownership of name argument. The constructor can accept it as a str
slice without loss of functionality. This reduces allocations when
creating ids since caller no longer has to have an owned string.
Replace From implementations with TryFrom implementations. Conversion
now fails if string is not in an epoch format. There’s still a way to
construct an identifier without epoch format if it comes from
tendermint::chain::Id (or by using ChainId::new with zero version;
behaviour of that might change). And since there’s From implementation
available, also get rid of ChainId::from_string.
Optimise epoch format parsing. `from_string` used to check if argument
was in epoch format and then call `chain_version` which did it again.
To avoid duplicating work, introduce `split_chain_id` method which does
the parsing and returns result which includes all the information
callers might want.
Similarly, calling `split` and collecting values into a vector is
wasteful if all we need is the last token. Furthermore, regexes are
quite a heavy machinery for the task of checking if string ends with
a number. To address that, use `split_last` and parse the number to
check if it’s valid.
0 commit comments