fix eth_feeHistory.

This commit is contained in:
Raúl Kripalani 2022-10-22 20:12:54 +01:00 committed by vyzo
parent 78dd7a246a
commit dc5fc9ded4
4 changed files with 17 additions and 17 deletions

View File

@ -786,7 +786,7 @@ type FullNode interface {
NetListening(ctx context.Context) (bool, error) //perm:read
EthProtocolVersion(ctx context.Context) (EthUint64, error) //perm:read
EthGasPrice(ctx context.Context) (EthBigInt, error) //perm:read
EthFeeHistory(ctx context.Context, blkCount uint64, newestBlk string, rewardPercentiles [][]int64) (EthFeeHistory, error) //perm:read
EthFeeHistory(ctx context.Context, blkCount EthUint64, newestBlk string, rewardPercentiles []int64) (EthFeeHistory, error) //perm:read
EthMaxPriorityFeePerGas(ctx context.Context) (EthBigInt, error) //perm:read
EthEstimateGas(ctx context.Context, tx EthCall) (EthUint64, error) //perm:read

View File

@ -997,7 +997,7 @@ func (mr *MockFullNodeMockRecorder) EthEstimateGas(arg0, arg1 interface{}) *gomo
}
// EthFeeHistory mocks base method.
func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 uint64, arg2 string, arg3 [][]int64) (api.EthFeeHistory, error) {
func (m *MockFullNode) EthFeeHistory(arg0 context.Context, arg1 api.EthUint64, arg2 string, arg3 []int64) (api.EthFeeHistory, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EthFeeHistory", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(api.EthFeeHistory)

View File

@ -230,7 +230,7 @@ type FullNodeStruct struct {
EthEstimateGas func(p0 context.Context, p1 EthCall) (EthUint64, error) `perm:"read"`
EthFeeHistory func(p0 context.Context, p1 uint64, p2 string, p3 [][]int64) (EthFeeHistory, error) `perm:"read"`
EthFeeHistory func(p0 context.Context, p1 EthUint64, p2 string, p3 []int64) (EthFeeHistory, error) `perm:"read"`
EthGasPrice func(p0 context.Context) (EthBigInt, error) `perm:"read"`
@ -1896,14 +1896,14 @@ func (s *FullNodeStub) EthEstimateGas(p0 context.Context, p1 EthCall) (EthUint64
return *new(EthUint64), ErrNotSupported
}
func (s *FullNodeStruct) EthFeeHistory(p0 context.Context, p1 uint64, p2 string, p3 [][]int64) (EthFeeHistory, error) {
func (s *FullNodeStruct) EthFeeHistory(p0 context.Context, p1 EthUint64, p2 string, p3 []int64) (EthFeeHistory, error) {
if s.Internal.EthFeeHistory == nil {
return *new(EthFeeHistory), ErrNotSupported
}
return s.Internal.EthFeeHistory(p0, p1, p2, p3)
}
func (s *FullNodeStub) EthFeeHistory(p0 context.Context, p1 uint64, p2 string, p3 [][]int64) (EthFeeHistory, error) {
func (s *FullNodeStub) EthFeeHistory(p0 context.Context, p1 EthUint64, p2 string, p3 []int64) (EthFeeHistory, error) {
return *new(EthFeeHistory), ErrNotSupported
}

View File

@ -45,7 +45,7 @@ type EthModuleAPI interface {
EthGetCode(ctx context.Context, address api.EthAddress, blkOpt string) (api.EthBytes, error)
EthGetStorageAt(ctx context.Context, address api.EthAddress, position api.EthBytes, blkParam string) (api.EthBytes, error)
EthGetBalance(ctx context.Context, address api.EthAddress, blkParam string) (api.EthBigInt, error)
EthFeeHistory(ctx context.Context, blkCount uint64, newestBlk string, rewardPercentiles [][]int64) (api.EthFeeHistory, error)
EthFeeHistory(ctx context.Context, blkCount api.EthUint64, newestBlk string, rewardPercentiles []int64) (api.EthFeeHistory, error)
EthChainId(ctx context.Context) (api.EthUint64, error)
NetVersion(ctx context.Context) (string, error)
NetListening(ctx context.Context) (bool, error)
@ -378,7 +378,7 @@ func (a *EthModule) EthChainId(ctx context.Context) (api.EthUint64, error) {
return api.EthUint64(build.Eip155ChainId), nil
}
func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount uint64, newestBlkNum string, rewardPercentiles [][]int64) (api.EthFeeHistory, error) {
func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount api.EthUint64, newestBlkNum string, rewardPercentiles []int64) (api.EthFeeHistory, error) {
if blkCount > 1024 {
return api.EthFeeHistory{}, fmt.Errorf("block count should be smaller than 1024")
}
@ -395,8 +395,8 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount uint64, newestBl
// Deal with the case that the chain is shorter than the number of
// requested blocks.
oldestBlkHeight := uint64(1)
if blkCount <= newestBlkHeight {
oldestBlkHeight = newestBlkHeight - blkCount + 1
if uint64(blkCount) <= newestBlkHeight {
oldestBlkHeight = newestBlkHeight - uint64(blkCount) + 1
}
ts, err := a.Chain.GetTipsetByHeight(ctx, abi.ChainEpoch(newestBlkHeight), nil, false)