Skip to content
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

Merged
merged 1 commit into from Aug 10, 2021

Conversation

zsfelfoldi
Copy link
Contributor

This PR allows both hex and decimal formats for the blockCount input parameter eth_feeHistory API.

Copy link
Member

@karalabe karalabe left a 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

@@ -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) {
Copy link
Member

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?

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@karalabe karalabe added this to the 1.10.7 milestone Aug 10, 2021
@karalabe karalabe merged commit 97bd6cd into ethereum:master Aug 10, 2021
sidhujag pushed a commit to sidhujag/go-ethereum that referenced this pull request Aug 15, 2021
reds pushed a commit to reds/go-ethereum that referenced this pull request Aug 28, 2021
i-norden pushed a commit to cerc-io/go-ethereum that referenced this pull request Sep 10, 2021
atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants