Skip to content

Commit 31d401e

Browse files
authored
rpc: remove DecimalOrHex type (#26629)
It's the same as math.HexOrDecimal64, which has more uses across the codebase.
1 parent cefc0fa commit 31d401e

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

internal/ethapi/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type feeHistoryResult struct {
8888
}
8989

9090
// FeeHistory returns the fee market history.
91-
func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*feeHistoryResult, error) {
91+
func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*feeHistoryResult, error) {
9292
oldest, reward, baseFee, gasUsed, err := s.b.FeeHistory(ctx, int(blockCount), lastBlock, rewardPercentiles)
9393
if err != nil {
9494
return nil, err

rpc/types.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -243,24 +243,3 @@ func BlockNumberOrHashWithHash(hash common.Hash, canonical bool) BlockNumberOrHa
243243
RequireCanonical: canonical,
244244
}
245245
}
246-
247-
// DecimalOrHex unmarshals a non-negative decimal or hex parameter into a uint64.
248-
type DecimalOrHex uint64
249-
250-
// UnmarshalJSON implements json.Unmarshaler.
251-
func (dh *DecimalOrHex) UnmarshalJSON(data []byte) error {
252-
input := strings.TrimSpace(string(data))
253-
if len(input) >= 2 && input[0] == '"' && input[len(input)-1] == '"' {
254-
input = input[1 : len(input)-1]
255-
}
256-
257-
value, err := strconv.ParseUint(input, 10, 64)
258-
if err != nil {
259-
value, err = hexutil.DecodeUint64(input)
260-
}
261-
if err != nil {
262-
return err
263-
}
264-
*dh = DecimalOrHex(value)
265-
return nil
266-
}

0 commit comments

Comments
 (0)