Skip to content

Commit

Permalink
GetRecentGasPrices fixes (#4295)
Browse files Browse the repository at this point in the history
* Avoid division by zero in stats_to_data

* Mark `utilization` required in `GasPrices`

* Support `int-as-string` in `GetRecentGasPrices`
  • Loading branch information
davidyuk committed Mar 11, 2024
1 parent 40de668 commit 347c3d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/aehttp/priv/oas3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,8 @@ paths:
- transaction
operationId: GetRecentGasPrices
description: 'Get minimum gas prices in recent blocks'
parameters: []
parameters:
- $ref: '#/components/parameters/intAsString'
responses:
'200':
description: 'Successful operation'
Expand Down Expand Up @@ -3948,15 +3949,18 @@ components:
$ref: "#/components/schemas/UInt"
utilization:
description: Percent of available gas used
type: integer
minimum: 0
maximum: 100
oneOf:
- type: integer
minimum: 0
maximum: 100
- type: string
minutes:
description: Number of minutes from the top
$ref: "#/components/schemas/UInt64"
required:
- min_gas_price
- minutes
- utilization
parameters:
intAsString:
in: query
Expand Down
3 changes: 3 additions & 0 deletions apps/aehttp/src/aehttp_logic.erl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ get_min_gas_price_since([{Ms, CutOff} | CutOffs] = COs, Hash, AccStats, Data) ->
{error, block_not_found}
end.

stats_to_data(Minutes, {MinGasPrice, 0, 0}) ->
stats_to_data(Minutes, {MinGasPrice, 0, 1});

stats_to_data(Minutes, {MinGasPrice, UsedGas, TotGas}) ->
{Minutes, min_gas_price(MinGasPrice), round((100 * UsedGas) / TotGas)}.

Expand Down

0 comments on commit 347c3d1

Please sign in to comment.