status-go/rpc/chain/ethclient/rps_limited_eth_client.go
Igor Sirotin c1dd9397f7
refactor_: remove generated files from source control (#5878)
* fix_: gitignore generated files

* chore_: delete generated files

* fix_: update go generate instructions

* feat(Makefile)_: clean-generated-files target

* feat(Makefile)_: `generate` target

* fix(Makefile)_: dependent generate target

* ci_: run generate, update docker file deps

* fix(Makefile)_: remove `clean-generated-files` target

* fix(Makefile)_: simpler GO_GENERATE_CMD arg

* fix_: temp workspace GO_GENERATE_FAST_DIR
2024-10-03 20:59:44 +01:00

47 lines
1.4 KiB
Go

package ethclient
//go:generate mockgen -package=mock_ethclient -source=rps_limited_eth_client.go -destination=mock/client/ethclient/rps_limited_eth_client.go
import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/status-im/status-go/rpc/chain/rpclimiter"
)
// RPSLimitedEthClientInterface extends EthClientInterface with additional
// RPS-Limiting related capabilities.
// Ideally this shouldn't exist, instead we should be using EthClientInterface
// everywhere and clients shouldn't be aware of additional capabilities like
// PRS limiting. fallback mechanisms or caching.
type RPSLimitedEthClientInterface interface {
EthClientInterface
GetLimiter() *rpclimiter.RPCRpsLimiter
GetName() string
CopyWithName(name string) RPSLimitedEthClientInterface
}
type RPSLimitedEthClient struct {
*EthClient
limiter *rpclimiter.RPCRpsLimiter
name string
}
func NewRPSLimitedEthClient(rpcClient *rpc.Client, limiter *rpclimiter.RPCRpsLimiter, name string) *RPSLimitedEthClient {
return &RPSLimitedEthClient{
EthClient: NewEthClient(rpcClient),
limiter: limiter,
name: name,
}
}
func (c *RPSLimitedEthClient) GetLimiter() *rpclimiter.RPCRpsLimiter {
return c.limiter
}
func (c *RPSLimitedEthClient) GetName() string {
return c.name
}
func (c *RPSLimitedEthClient) CopyWithName(name string) RPSLimitedEthClientInterface {
return NewRPSLimitedEthClient(c.rpcClient, c.limiter, name)
}