@@ -856,6 +856,21 @@ func (b *BlockChainAPI) FeeHistory(
856856 )
857857
858858 maxCount := min (uint64 (blockCount ), lastBlockNumber )
859+
860+ blockRewards := make ([]* hexutil.Big , len (rewardPercentiles ))
861+ gasPrice := b .config .GasPrice
862+
863+ feeParams , err := b .feeParameters .Get ()
864+ if err != nil {
865+ b .logger .Warn ().Err (err ).Msg ("fee parameters unavailable; falling back to base gas price" )
866+ } else {
867+ gasPrice = feeParams .CalculateGasPrice (b .config .GasPrice )
868+ }
869+
870+ for i := range rewardPercentiles {
871+ blockRewards [i ] = (* hexutil .Big )(gasPrice )
872+ }
873+
859874 for i := maxCount ; i >= uint64 (1 ); i -- {
860875 // If the requested block count is 5, and the last block number
861876 // is 20, then we need the blocks [16, 17, 18, 19, 20] in this
@@ -872,21 +887,6 @@ func (b *BlockChainAPI) FeeHistory(
872887
873888 baseFees = append (baseFees , (* hexutil .Big )(models .BaseFeePerGas ))
874889
875- blockRewards := make ([]* hexutil.Big , len (rewardPercentiles ))
876- feeParams , err := b .feeParameters .Get ()
877- if err != nil {
878- b .logger .Warn ().
879- Uint64 ("height" , blockHeight ).
880- Err (err ).
881- Msg ("failed to get fee parameters for block in fee history" )
882-
883- continue
884- }
885- gasPrice := feeParams .CalculateGasPrice (b .config .GasPrice )
886- for i := range rewardPercentiles {
887- blockRewards [i ] = (* hexutil .Big )(gasPrice )
888- }
889-
890890 rewards = append (rewards , blockRewards )
891891
892892 gasUsedRatio := float64 (block .TotalGasUsed ) / float64 (BlockGasLimit )
0 commit comments