mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Add support for JSON decimal integer block numbers
This commit is contained in:
parent
5b4438d6bb
commit
fab8333bd2
1 changed files with 6 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
|
|
@ -135,6 +136,11 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
|
|||
input := strings.TrimSpace(string(data))
|
||||
if len(input) >= 2 && input[0] == '"' && input[len(input)-1] == '"' {
|
||||
input = input[1 : len(input)-1]
|
||||
} else {
|
||||
// Integer block number
|
||||
value, err := strconv.Atoi(string(data))
|
||||
*bn = BlockNumber(value)
|
||||
return err
|
||||
}
|
||||
|
||||
switch input {
|
||||
|
|
|
|||
Loading…
Reference in a new issue