Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
f86f0486
Unverified
Commit
f86f0486
authored
Feb 22, 2023
by
Péter Szilágyi
Committed by
GitHub
Feb 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common/math: allow HexOrDecimal to accept unquoted decimals too (#26758)
parent
4034c675
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
big.go
common/math/big.go
+11
-0
integer.go
common/math/integer.go
+11
-0
No files found.
common/math/big.go
View file @
f86f0486
...
...
@@ -49,6 +49,17 @@ func NewHexOrDecimal256(x int64) *HexOrDecimal256 {
return
&
h
}
// UnmarshalJSON implements json.Unmarshaler.
//
// It is similar to UnmarshalText, but allows parsing real decimals too, not just
// quoted decimal strings.
func
(
i
*
HexOrDecimal256
)
UnmarshalJSON
(
input
[]
byte
)
error
{
if
len
(
input
)
>
0
&&
input
[
0
]
==
'"'
{
input
=
input
[
1
:
len
(
input
)
-
1
]
}
return
i
.
UnmarshalText
(
input
)
}
// UnmarshalText implements encoding.TextUnmarshaler.
func
(
i
*
HexOrDecimal256
)
UnmarshalText
(
input
[]
byte
)
error
{
bigint
,
ok
:=
ParseBig256
(
string
(
input
))
...
...
common/math/integer.go
View file @
f86f0486
...
...
@@ -41,6 +41,17 @@ const (
// HexOrDecimal64 marshals uint64 as hex or decimal.
type
HexOrDecimal64
uint64
// UnmarshalJSON implements json.Unmarshaler.
//
// It is similar to UnmarshalText, but allows parsing real decimals too, not just
// quoted decimal strings.
func
(
i
*
HexOrDecimal64
)
UnmarshalJSON
(
input
[]
byte
)
error
{
if
len
(
input
)
>
0
&&
input
[
0
]
==
'"'
{
input
=
input
[
1
:
len
(
input
)
-
1
]
}
return
i
.
UnmarshalText
(
input
)
}
// UnmarshalText implements encoding.TextUnmarshaler.
func
(
i
*
HexOrDecimal64
)
UnmarshalText
(
input
[]
byte
)
error
{
int
,
ok
:=
ParseUint64
(
string
(
input
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment