fee

package
v1.11.12-ubuntu-noble.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Target                   gas.Gas   `json:"target"`
	MinPrice                 gas.Price `json:"minPrice"`
	ExcessConversionConstant gas.Gas   `json:"excessConversionConstant"`
}

Config contains all the static parameters of the dynamic fee mechanism.

type State

type State struct {
	Current gas.Gas `json:"current"`
	Excess  gas.Gas `json:"excess"`
}

State represents the current on-chain values used in the dynamic fee mechanism.

func (State) AdvanceTime

func (s State) AdvanceTime(target gas.Gas, seconds uint64) State

AdvanceTime adds (s.Current - target) * seconds to Excess.

If Excess would underflow, it is set to 0. If Excess would overflow, it is set to MaxUint64.

func (State) CostOf

func (s State) CostOf(c Config, seconds uint64) uint64

CostOf calculates how much to charge based on the dynamic fee mechanism for seconds.

This implements the ACP-77 cost over time formula:

func (State) SecondsRemaining

func (s State) SecondsRemaining(c Config, maxSeconds uint64, fundsRemaining uint64) uint64

SecondsRemaining calculates the maximum number of seconds that a validator can pay fees before their fundsRemaining would be exhausted based on the dynamic fee mechanism. The result is capped at maxSeconds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL