fix: Convert big integers to float64
Large numbers can be returned by the Flexpool API reaching the `int64` limit. Blocks reward were seen as 0 ETH. Using `float64` instead. Also converting signed int64 to unsigned int64 for non-timestamp numbers. BREAKING CHANGE: please follow the upgrades instructions from 1.2 to 1.3 to convert such types in the database. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
ac0903cf9d
commit
3d4c049323
7 changed files with 63 additions and 25 deletions
10
utils.go
10
utils.go
|
|
@ -12,7 +12,7 @@ const MojoToXCHDivider = 1000000000000
|
|||
|
||||
// ConvertCurrency divides the smallest unit of the currency to the currency itself
|
||||
// Example: for "eth", convert from Weis to ETH
|
||||
func ConvertCurrency(coin string, value int64) (float64, error) {
|
||||
func ConvertCurrency(coin string, value float64) (float64, error) {
|
||||
switch coin {
|
||||
case "eth":
|
||||
return ConvertWeis(value), nil
|
||||
|
|
@ -24,13 +24,13 @@ func ConvertCurrency(coin string, value int64) (float64, error) {
|
|||
}
|
||||
|
||||
// ConvertWeis converts the value from Weis to ETH
|
||||
func ConvertWeis(value int64) float64 {
|
||||
return float64(value) / WeisToETHDivider
|
||||
func ConvertWeis(value float64) float64 {
|
||||
return value / WeisToETHDivider
|
||||
}
|
||||
|
||||
// ConvertMojo converts the value from Mojo to XCH
|
||||
func ConvertMojo(value int64) float64 {
|
||||
return float64(value) / MojoToXCHDivider
|
||||
func ConvertMojo(value float64) float64 {
|
||||
return value / MojoToXCHDivider
|
||||
}
|
||||
|
||||
// ConvertAction returns "Miner" for Ethereum and "Farmer" for Chia
|
||||
|
|
|
|||
Reference in a new issue