fee

package
v1.11.12-oidc-test Latest Latest
Warning

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

Go to latest
Published: Sep 13, 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) SecondsUntil

func (s State) SecondsUntil(c Config, maxSeconds uint64, targetCost uint64) uint64

SecondsUntil calculates the number of seconds that it would take to charge at least [targetCost] 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