common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: GPL-3.0 Imports: 12 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EvmGas = func(chainType string) *Gas {
		switch chainType {
		case tokSchema.OracleEthChainType:
			return NewGas(map[string]func(url string) (fastestETH float64, fastETH float64, averageETH float64, err error){
				"https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=MYDQVP2XTAE7DCPACT9NMZ9CQX558M2WWS": GetGasEtherscan,
				"https://api.blocknative.com/gasprices/blockprices":                                                         GetGasBlockNative,
			})
		case tokSchema.OracleMoonChainType:
			return NewGas(map[string]func(url string) (fastestETH float64, fastETH float64, averageETH float64, err error){
				"https://rpc.api.moonbeam.network": GetGasNode,
			})
		case tokSchema.OracleCfxChainType:
			return NewGas(map[string]func(url string) (fastestETH float64, fastETH float64, averageETH float64, err error){
				"https://evm.confluxrpc.com": GetGasNode,
			})
		}
		return nil
	}
)

Functions

func GetGasBlockNative

func GetGasBlockNative(url string) (fastestETH, fastETH, averageETH float64, err error)

func GetGasEtherscan

func GetGasEtherscan(url string) (fastestETH, fastETH, averageETH float64, err error)

func GetGasNode

func GetGasNode(rpc string) (fastestETH, fastETH, averageETH float64, err error)

func NewLog

func NewLog(serverName string) log15.Logger

Types

type Gas

type Gas struct {
	// contains filtered or unexported fields
}

func NewGas

func NewGas(gasFuncMap map[string]func(url string) (fastestETH, fastETH, averageETH float64, err error)) *Gas

func (*Gas) Average

func (g *Gas) Average() float64

func (*Gas) Fast

func (g *Gas) Fast() float64

func (*Gas) Fastest

func (g *Gas) Fastest() float64

func (*Gas) GetGasPrice

func (g *Gas) GetGasPrice() (fastestETH, fastETH, averageETH float64, source string, err error)

func (*Gas) Run

func (g *Gas) Run()

func (*Gas) Source

func (g *Gas) Source() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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