|
|
@ -19,6 +19,7 @@ package rpc |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"context" |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
|
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"math" |
|
|
|
"math" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
@ -104,7 +105,7 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
if blckNum > math.MaxInt64 { |
|
|
|
if blckNum > math.MaxInt64 { |
|
|
|
return fmt.Errorf("block number larger than int64") |
|
|
|
return errors.New("block number larger than int64") |
|
|
|
} |
|
|
|
} |
|
|
|
*bn = BlockNumber(blckNum) |
|
|
|
*bn = BlockNumber(blckNum) |
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -154,7 +155,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error { |
|
|
|
err := json.Unmarshal(data, &e) |
|
|
|
err := json.Unmarshal(data, &e) |
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
if e.BlockNumber != nil && e.BlockHash != nil { |
|
|
|
if e.BlockNumber != nil && e.BlockHash != nil { |
|
|
|
return fmt.Errorf("cannot specify both BlockHash and BlockNumber, choose one or the other") |
|
|
|
return errors.New("cannot specify both BlockHash and BlockNumber, choose one or the other") |
|
|
|
} |
|
|
|
} |
|
|
|
bnh.BlockNumber = e.BlockNumber |
|
|
|
bnh.BlockNumber = e.BlockNumber |
|
|
|
bnh.BlockHash = e.BlockHash |
|
|
|
bnh.BlockHash = e.BlockHash |
|
|
@ -202,7 +203,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
if blckNum > math.MaxInt64 { |
|
|
|
if blckNum > math.MaxInt64 { |
|
|
|
return fmt.Errorf("blocknumber too high") |
|
|
|
return errors.New("blocknumber too high") |
|
|
|
} |
|
|
|
} |
|
|
|
bn := BlockNumber(blckNum) |
|
|
|
bn := BlockNumber(blckNum) |
|
|
|
bnh.BlockNumber = &bn |
|
|
|
bnh.BlockNumber = &bn |
|
|
|