all: simplify timestamps to uint64 (#19372)

* all: simplify timestamps to uint64

* tests: update definitions

* clef, faucet, mobile: leftover uint64 fixups

* ethash: fix tests

* graphql: update schema for timestamp

* ethash: remove unused variable
This commit is contained in:
Martin Holst Swende
2019-04-02 22:28:48 +02:00
committed by Péter Szilágyi
parent e14f8a408c
commit 0b4fe8d192
27 changed files with 85 additions and 89 deletions

View File

@ -14,6 +14,7 @@ import (
var _ = (*btHeaderMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (b btHeader) MarshalJSON() ([]byte, error) {
type btHeader struct {
Bloom types.Bloom
@ -31,7 +32,7 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
Difficulty *math.HexOrDecimal256
GasLimit math.HexOrDecimal64
GasUsed math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
Timestamp math.HexOrDecimal64
}
var enc btHeader
enc.Bloom = b.Bloom
@ -49,10 +50,11 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
enc.GasLimit = math.HexOrDecimal64(b.GasLimit)
enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp)
enc.Timestamp = math.HexOrDecimal64(b.Timestamp)
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (b *btHeader) UnmarshalJSON(input []byte) error {
type btHeader struct {
Bloom *types.Bloom
@ -70,7 +72,7 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
Difficulty *math.HexOrDecimal256
GasLimit *math.HexOrDecimal64
GasUsed *math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
Timestamp *math.HexOrDecimal64
}
var dec btHeader
if err := json.Unmarshal(input, &dec); err != nil {
@ -122,7 +124,7 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
b.GasUsed = uint64(*dec.GasUsed)
}
if dec.Timestamp != nil {
b.Timestamp = (*big.Int)(dec.Timestamp)
b.Timestamp = uint64(*dec.Timestamp)
}
return nil
}