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
97bd6cd2
Unverified
Commit
97bd6cd2
authored
Aug 10, 2021
by
Felföldi Zsolt
Committed by
GitHub
Aug 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal/ethapi: accept both hex and decimal for blockCount (#23363)
parent
d60cfd26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
api.go
internal/ethapi/api.go
+1
-1
types.go
rpc/types.go
+22
-0
No files found.
internal/ethapi/api.go
View file @
97bd6cd2
...
...
@@ -87,7 +87,7 @@ type feeHistoryResult struct {
GasUsedRatio
[]
float64
`json:"gasUsedRatio"`
}
func
(
s
*
PublicEthereumAPI
)
FeeHistory
(
ctx
context
.
Context
,
blockCount
hexutil
.
Uint
,
lastBlock
rpc
.
BlockNumber
,
rewardPercentiles
[]
float64
)
(
*
feeHistoryResult
,
error
)
{
func
(
s
*
PublicEthereumAPI
)
FeeHistory
(
ctx
context
.
Context
,
blockCount
rpc
.
DecimalOrHex
,
lastBlock
rpc
.
BlockNumber
,
rewardPercentiles
[]
float64
)
(
*
feeHistoryResult
,
error
)
{
oldest
,
reward
,
baseFee
,
gasUsed
,
err
:=
s
.
b
.
FeeHistory
(
ctx
,
int
(
blockCount
),
lastBlock
,
rewardPercentiles
)
if
err
!=
nil
{
return
nil
,
err
...
...
rpc/types.go
View file @
97bd6cd2
...
...
@@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"math"
"strconv"
"strings"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -191,3 +192,24 @@ func BlockNumberOrHashWithHash(hash common.Hash, canonical bool) BlockNumberOrHa
RequireCanonical
:
canonical
,
}
}
// DecimalOrHex unmarshals a non-negative decimal or hex parameter into a uint64.
type
DecimalOrHex
uint64
// UnmarshalJSON implements json.Unmarshaler.
func
(
dh
*
DecimalOrHex
)
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
]
}
value
,
err
:=
strconv
.
ParseUint
(
input
,
10
,
64
)
if
err
!=
nil
{
value
,
err
=
hexutil
.
DecodeUint64
(
input
)
}
if
err
!=
nil
{
return
err
}
*
dh
=
DecimalOrHex
(
value
)
return
nil
}
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