@@ -820,6 +820,21 @@ func (b *BlockChainAPI) FeeHistory(
820820 )
821821
822822 maxCount := min (uint64 (blockCount ), lastBlockNumber )
823+
824+ blockRewards := make ([]* hexutil.Big , len (rewardPercentiles ))
825+ gasPrice := b .config .GasPrice
826+
827+ feeParams , err := b .feeParameters .Get ()
828+ if err != nil {
829+ b .logger .Warn ().Err (err ).Msg ("fee parameters unavailable; falling back to base gas price" )
830+ } else {
831+ gasPrice = feeParams .CalculateGasPrice (b .config .GasPrice )
832+ }
833+
834+ for i := range rewardPercentiles {
835+ blockRewards [i ] = (* hexutil .Big )(gasPrice )
836+ }
837+
823838 for i := maxCount ; i >= uint64 (1 ); i -- {
824839 // If the requested block count is 5, and the last block number
825840 // is 20, then we need the blocks [16, 17, 18, 19, 20] in this
@@ -836,21 +851,6 @@ func (b *BlockChainAPI) FeeHistory(
836851
837852 baseFees = append (baseFees , (* hexutil .Big )(models .BaseFeePerGas ))
838853
839- blockRewards := make ([]* hexutil.Big , len (rewardPercentiles ))
840- feeParams , err := b .feeParameters .Get ()
841- if err != nil {
842- b .logger .Warn ().
843- Uint64 ("height" , blockHeight ).
844- Err (err ).
845- Msg ("failed to get fee parameters for block in fee history" )
846-
847- continue
848- }
849- gasPrice := feeParams .CalculateGasPrice (b .config .GasPrice )
850- for i := range rewardPercentiles {
851- blockRewards [i ] = (* hexutil .Big )(gasPrice )
852- }
853-
854854 rewards = append (rewards , blockRewards )
855855
856856 gasUsedRatio := float64 (block .TotalGasUsed ) / float64 (BlockGasLimit )
0 commit comments