Documentation
¶
Index ¶
- Constants
- func NewFlatWave(config WaveConfig) *wave
- func NewSawtoothWave(config WaveConfig) *wave
- func NewSineWave(config WaveConfig) *wave
- func NewSquareWave(config WaveConfig) *wave
- func NewTriangleWave(config WaveConfig) *wave
- type DynamicGasPriceConfig
- type DynamicGasPriceStrategy
- type EstimatedGasPriceStrategy
- type FixedGasPriceConfig
- type FixedGasPriceStrategy
- type FlatWave
- type GasPricer
- type GasProvider
- type GasProviderBase
- type GasVault
- type OscillatingGasProvider
- type PriceStrategy
- type SawtoothWave
- type SineWave
- type SquareWave
- type TriangleWave
- type Wave
- type WaveConfig
- type WaveType
Constants ¶
const DefaultPollInterval = 1 * time.Second
DefaultPollInterval is the default interval for polling new block headers.
Variables ¶
This section is empty.
Functions ¶
func NewSawtoothWave ¶
func NewSawtoothWave(config WaveConfig) *wave
NewSawtoothWave creates a new sawtooth wave.
func NewSquareWave ¶
func NewSquareWave(config WaveConfig) *wave
NewSquareWave creates a new square wave.
func NewTriangleWave ¶
func NewTriangleWave(config WaveConfig) *wave
NewTriangleWave creates a new triangle wave.
Types ¶
type DynamicGasPriceConfig ¶
DynamicGasPriceConfig holds the configuration for the DynamicGasPriceStrategy.
type DynamicGasPriceStrategy ¶
type DynamicGasPriceStrategy struct {
// contains filtered or unexported fields
}
DynamicGasPriceStrategy provides gas prices from a predefined list with random variation.
func NewDynamicGasPriceStrategy ¶
func NewDynamicGasPriceStrategy(config DynamicGasPriceConfig) (*DynamicGasPriceStrategy, error)
NewDynamicGasPriceStrategy creates a new DynamicGasPriceStrategy with the given configuration.
func (*DynamicGasPriceStrategy) GetGasPrice ¶
func (s *DynamicGasPriceStrategy) GetGasPrice() *uint64
GetGasPrice retrieves the next gas price from the list, applying random variation.
type EstimatedGasPriceStrategy ¶
type EstimatedGasPriceStrategy struct {
}
EstimatedGasPriceStrategy provides gas prices estimated from the network.
func NewEstimatedGasPriceStrategy ¶
func NewEstimatedGasPriceStrategy() *EstimatedGasPriceStrategy
NewEstimatedGasPriceStrategy creates a new EstimatedGasPriceStrategy.
func (*EstimatedGasPriceStrategy) GetGasPrice ¶
func (s *EstimatedGasPriceStrategy) GetGasPrice() *uint64
GetGasPrice retrieves the estimated gas price from the network. For this strategy, we return nil to indicate that the default network gas price should be used.
type FixedGasPriceConfig ¶
type FixedGasPriceConfig struct {
GasPriceWei uint64
}
FixedGasPriceConfig holds the configuration for the FixedGasPriceStrategy.
type FixedGasPriceStrategy ¶
type FixedGasPriceStrategy struct {
// contains filtered or unexported fields
}
FixedGasPriceStrategy provides a fixed gas price.
func NewFixedGasPriceStrategy ¶
func NewFixedGasPriceStrategy(config FixedGasPriceConfig) *FixedGasPriceStrategy
NewFixedGasPriceStrategy creates a new FixedGasPriceStrategy with the given configuration.
func (*FixedGasPriceStrategy) GetGasPrice ¶
func (s *FixedGasPriceStrategy) GetGasPrice() *uint64
GetGasPrice retrieves the fixed gas price.
type FlatWave ¶
type FlatWave = wave
FlatWave is an alias for wave (kept for backwards compatibility).
type GasPricer ¶
type GasPricer struct {
// contains filtered or unexported fields
}
GasPricer uses a PriceStrategy to determine the gas price.
func NewGasPricer ¶
func NewGasPricer(strategy PriceStrategy) *GasPricer
NewGasPricer creates a new GasPricer with the given PriceStrategy.
func (*GasPricer) GetGasPrice ¶
GetGasPrice retrieves the gas price using the configured PriceStrategy.
type GasProvider ¶
GasProvider defines the interface for gas providers.
type GasProviderBase ¶
type GasProviderBase struct {
// contains filtered or unexported fields
}
GasProviderBase provides common functionality for gas providers.
func NewGasProviderBase ¶
func NewGasProviderBase(client *ethclient.Client, vault *GasVault) *GasProviderBase
NewGasProviderBase creates a new GasProviderBase with the given Ethereum client and gas vault.
func (*GasProviderBase) SetPollInterval ¶
func (o *GasProviderBase) SetPollInterval(interval time.Duration)
SetPollInterval sets the interval for polling new block headers.
func (*GasProviderBase) Start ¶
func (o *GasProviderBase) Start(ctx context.Context)
Start begins the operation of the GasProviderBase by starting to watch for new block headers.
type GasVault ¶
type GasVault struct {
// contains filtered or unexported fields
}
GasVault manages a budget of gas that can be added to and spent from.
func (*GasVault) GetAvailableBudget ¶
GetAvailableBudget returns the current available gas budget in the vault.
func (*GasVault) SpendOrWaitAvailableBudget ¶
SpendOrWaitAvailableBudget attempts to spend the specified amount of gas from the vault's available budget. It blocks until sufficient budget is available or the context is cancelled.
type OscillatingGasProvider ¶
type OscillatingGasProvider struct {
GasProviderBase
// contains filtered or unexported fields
}
OscillatingGasProvider is a gas provider that adds gas to the vault based on an oscillating wave pattern.
func NewOscillatingGasProvider ¶
func NewOscillatingGasProvider(client *ethclient.Client, vault *GasVault, wave Wave) *OscillatingGasProvider
NewOscillatingGasProvider creates a new OscillatingGasProvider with the given Ethereum client, gas vault, and wave pattern. It also sets up the necessary callbacks for starting and processing new block headers.
func (*OscillatingGasProvider) Start ¶
func (o *OscillatingGasProvider) Start(ctx context.Context)
Start begins the operation of the OscillatingGasProvider by invoking the Start method of its base class.
type PriceStrategy ¶
type PriceStrategy interface {
GetGasPrice() *uint64
}
PriceStrategy defines the interface for different gas price strategies.
type SawtoothWave ¶
type SawtoothWave = wave
SawtoothWave is an alias for wave (kept for backwards compatibility).
type SineWave ¶
type SineWave = wave
SineWave is an alias for wave (kept for backwards compatibility).
type SquareWave ¶
type SquareWave = wave
SquareWave is an alias for wave (kept for backwards compatibility).
type TriangleWave ¶
type TriangleWave = wave
TriangleWave is an alias for wave (kept for backwards compatibility).
type Wave ¶
type Wave interface {
Period() uint64
Amplitude() uint64
Target() uint64
X() float64
Y() float64
MoveNext()
}
Wave interface for all wave types.
func NewWave ¶
func NewWave(waveType WaveType, config WaveConfig) Wave
NewWave creates a new wave of the specified type with the given configuration.
type WaveConfig ¶
WaveConfig holds the configuration for a wave.