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

RpcServerSettings should use new BigDecimal decimal constructor instead of Parse #472

Closed
devhawk opened this issue Jan 19, 2021 · 2 comments · Fixed by #476
Closed

RpcServerSettings should use new BigDecimal decimal constructor instead of Parse #472

devhawk opened this issue Jan 19, 2021 · 2 comments · Fixed by #476

Comments

@devhawk
Copy link
Contributor

devhawk commented Jan 19, 2021

converting decimal to BigDecimal by converting to string and then parsing is inefficient and subject to globalization errors like #466. The RpcServerSettings ctor should use the new decimal constructor (neo-project/neo#2246) once it's available

@chenzhitong
Copy link
Member

chenzhitong commented Jan 19, 2021

string input = "1,234.01";
var a = (long)BigDecimal.Parse(input, NativeContract.GAS.Decimals).Value;
var b = new BigDecimal(Convert.ToDecimal(input));

It seems that we can't use new BigDecimal instead of BigDecimal.Parse
because the two values are not equal.

You see, whether this PR neo-project/neo#2248 is useful?

@devhawk
Copy link
Contributor Author

devhawk commented Jan 19, 2021

@chenzhitong I'm suggesting that we don't use BigDecimal.Parse to convert maxGasInvoke and maxFee decimal values to BigDecimal in this code:

this.MaxGasInvoke = (long)BigDecimal.Parse(maxGasInvoke.ToString(CultureInfo.InvariantCulture), NativeContract.GAS.Decimals).Value;
this.MaxFee = (long)BigDecimal.Parse(maxFee.ToString(CultureInfo.InvariantCulture), NativeContract.GAS.Decimals).Value;

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

Successfully merging a pull request may close this issue.

2 participants