Repository navigation
fix(types): use f64 for GetMiningInfo networkhashps field - #440
Conversation
|
Took me a minute to work out why the original test did not catch this bug. And the reason seems to be that when networkhashps is zero, Core returns Adding |
| // v29 added fields (bits, target) that can fail to parse. | ||
| #[cfg(not(feature = "v28_and_below"))] | ||
| { | ||
| let model: Result<mtype::GetMiningInfo, GetMiningInfoError> = json.into_model(); |
There was a problem hiding this comment.
We want to keep this line with the explicit Result type. The reason we do this is to ensure that we exported all the error types correctly. In the past before we did this we forgot a bunch of them.
There was a problem hiding this comment.
FTR most of the 'weird' stuff here is for a specific reason, not always obvious. Feel free to ask about anything that looks odd. Also if anything is non-uniform them we probably made a mistake - it happens.
There was a problem hiding this comment.
Noted, thanks for the info
|
|
||
| assert!(model.network_hash_ps > 0.0); | ||
| } | ||
|
|
There was a problem hiding this comment.
Do what you think is best but to me it looks like the only real changes needed to this test are adding the wallet funding and adding the assertion on network_hash_ps.
Bitcoin Core returns networkhashps as a double. The previous type (i64) causes deserialisation to fail.
f01c4a9 to
a36ab10
Compare
As per raised in #429, addressing type discrepancies between corepc-types and Bitcoin Core.
Bitcoin Core has always returned
networkhashpsas a double sincegetmininginfowas introduced. The previous type (i64) causes deserialisation to fail. Here's a minimal example:This change:
networkhashpsfield type fromi64tof64networkhashps> 0.0) and remove redundant comments