-
Notifications
You must be signed in to change notification settings - Fork 20.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal/ethapi: accept both hex and decimal for blockCount #23363
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nonononon :D
Please make a new type rpc.DecimalOrHex
inside rpc/types.go
and add a custom JSON unmarshaller, similar to https://github.com/ethereum/go-ethereum/blob/master/rpc/types.go#L71
internal/ethapi/api.go
Outdated
@@ -87,8 +87,23 @@ type feeHistoryResult struct { | |||
GasUsedRatio []float64 `json:"gasUsedRatio"` | |||
} | |||
|
|||
func (s *PublicEthereumAPI) FeeHistory(ctx context.Context, blockCount hexutil.Uint, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*feeHistoryResult, error) { | |||
oldest, reward, baseFee, gasUsed, err := s.b.FeeHistory(ctx, int(blockCount), lastBlock, rewardPercentiles) | |||
func (s *PublicEthereumAPI) FeeHistory(ctx context.Context, blockCount interface{}, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*feeHistoryResult, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps defining the rpc.HexUintOrUint
type to resolve the value from the json stream is better?
83c4a9c
to
5e95b5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR allows both hex and decimal formats for the blockCount input parameter eth_feeHistory API.