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
pool.go
10
pool.go
|
@ -10,7 +10,7 @@ import (
|
|||
type Pool struct {
|
||||
gorm.Model
|
||||
Coin string `gorm:"unique;not null"`
|
||||
LastBlockNumber int64
|
||||
LastBlockNumber uint64
|
||||
}
|
||||
|
||||
// NewPool creates a Pool
|
||||
|
@ -25,13 +25,13 @@ func (p *Pool) String() string {
|
|||
|
||||
// Block to store block attributes
|
||||
type Block struct {
|
||||
Hash string `gorm:"unique;not null"`
|
||||
Number int64 `gorm:"not null"`
|
||||
Reward int64 `gorm:"not null"`
|
||||
Hash string `gorm:"unique;not null"`
|
||||
Number uint64 `gorm:"not null"`
|
||||
Reward float64 `gorm:"not null"`
|
||||
}
|
||||
|
||||
// NewBlock creates a Block
|
||||
func NewBlock(hash string, number int64, reward int64) *Block {
|
||||
func NewBlock(hash string, number uint64, reward float64) *Block {
|
||||
return &Block{
|
||||
Hash: hash,
|
||||
Number: number,
|
||||
|
|
Reference in a new issue