common

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package common includes common utilities

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingRelayPubkey = fmt.Errorf("missing relay public key")
	ErrURLEmpty           = errors.New("url is empty")
)

Functions

func BeginningOfDay added in v1.8.2

func BeginningOfDay(t time.Time) time.Time

func Check added in v1.8.2

func Check(err error)

func EthToWei

func EthToWei(eth *big.Int) *big.Float

func GetMemMB added in v1.8.2

func GetMemMB() uint64

func GetURI

func GetURI(url *url.URL, path string) string

GetURI returns the full request URI with scheme, host, path and args.

func GetURIWithQuery added in v1.8.2

func GetURIWithQuery(url *url.URL, path string, queryArgs map[string]string) string

func HumanBytes added in v1.8.2

func HumanBytes(n uint64) string

HumanBytes returns size in the same format as AWS S3

func LogSetup

func LogSetup(json bool, logLevel string, logDebug bool) *logrus.Entry

func MustConnectBeaconNode added in v1.8.2

func MustConnectBeaconNode(log *logrus.Entry, beaconNodeURI string, allowSyncing bool) (bn *beaconclient.ProdBeaconInstance, headSlot uint64)

func MustGetLatestSlot added in v1.9.0

func MustGetLatestSlot() uint64

func MustParseDateTimeStr added in v1.8.2

func MustParseDateTimeStr(s string) time.Time

func PercentDiff

func PercentDiff(x, y *big.Int) *big.Float

func RelayEntriesToHostnameStrings added in v1.8.2

func RelayEntriesToHostnameStrings(relays []RelayEntry) []string

RelayEntriesToHostnameStrings returns the hostnames of a list of relay entries

func RelayEntriesToStrings

func RelayEntriesToStrings(relays []RelayEntry) []string

RelayEntriesToStrings returns the string representation of a list of relay entries

func ReverseBytes added in v1.8.2

func ReverseBytes(src []byte) []byte

func SendHTTPRequest

func SendHTTPRequest(ctx context.Context, client http.Client, method, url string, payload, dst any) (code int, err error)

func SlotToTime added in v1.8.2

func SlotToTime(slot uint64) time.Time

func StrToBigInt

func StrToBigInt(s string) *big.Int

func StringSliceContains

func StringSliceContains(haystack []string, needle string) bool

func TimeToSlot added in v1.8.2

func TimeToSlot(t time.Time) uint64

func WeiStrToEthStr

func WeiStrToEthStr(wei string, decimals int) string

func WeiToEth

func WeiToEth(wei *big.Int) (ethValue *big.Float)

func WeiToEthStr

func WeiToEthStr(wei *big.Int) string

Types

type Address added in v1.8.2

type Address [20]byte

type EthNode added in v1.8.2

type EthNode struct {
	Clients []*ethclient.Client
}

func NewEthNode added in v1.8.2

func NewEthNode(uris ...string) (*EthNode, error)

func (*EthNode) BlockByHash added in v1.8.2

func (n *EthNode) BlockByHash(blockHash string) (block *types.Block, err error)

func (*EthNode) BlockByNumber added in v1.8.2

func (n *EthNode) BlockByNumber(blockNumber int64) (block *types.Block, err error)

func (*EthNode) GetBalanceDiff added in v1.8.2

func (n *EthNode) GetBalanceDiff(address string, blockNumber int64) (diff *big.Int, err error)

type Hash added in v1.8.2

type Hash [32]byte

type PublicKey added in v1.8.2

type PublicKey [48]byte

type RelayEntry

type RelayEntry struct {
	PublicKey types.PublicKey
	URL       *url.URL
}

RelayEntry represents a relay that mev-boost connects to.

func GetRelays

func GetRelays() ([]RelayEntry, error)

func MustGetRelays added in v1.8.2

func MustGetRelays() []RelayEntry

func MustNewRelayEntry added in v1.8.2

func MustNewRelayEntry(relayURL string, requireUser bool) (entry RelayEntry)

func NewRelayEntry

func NewRelayEntry(relayURL string, requireUser bool) (entry RelayEntry, err error)

NewRelayEntry creates a new instance based on an input string relayURL can be IP@PORT, PUBKEY@IP:PORT, https://IP, etc.

func (*RelayEntry) GetURI

func (r *RelayEntry) GetURI(path string) string

GetURI returns the full request URI with scheme, host, path and args for the relay.

func (*RelayEntry) Hostname

func (r *RelayEntry) Hostname() string

func (*RelayEntry) String

func (r *RelayEntry) String() string

type U256 added in v1.8.2

type U256 [32]byte

func (*U256) String added in v1.8.2

func (n *U256) String() string

type U64 added in v1.8.2

type U64 [8]byte

type UltrasoundStreamBid added in v1.8.2

type UltrasoundStreamBid struct {
	Timestamp     uint64    `json:"timestamp"`
	Slot          uint64    `json:"slot"`
	BlockNumber   uint64    `json:"block_number"`
	BlockHash     Hash      `json:"block_hash" ssz-size:"32"`
	ParentHash    Hash      `json:"parent_hash" ssz-size:"32"`
	BuilderPubkey PublicKey `json:"builder_pubkey" ssz-size:"48"`
	FeeRecipient  Address   `json:"fee_recipient" ssz-size:"20"`
	Value         U256      `json:"value" ssz-size:"32"`
}

func (*UltrasoundStreamBid) GetTree added in v1.8.2

func (u *UltrasoundStreamBid) GetTree() (*ssz.Node, error)

GetTree ssz hashes the UltrasoundStreamBid object

func (*UltrasoundStreamBid) HashTreeRoot added in v1.8.2

func (u *UltrasoundStreamBid) HashTreeRoot() ([32]byte, error)

HashTreeRoot ssz hashes the UltrasoundStreamBid object

func (*UltrasoundStreamBid) HashTreeRootWith added in v1.8.2

func (u *UltrasoundStreamBid) HashTreeRootWith(hh ssz.HashWalker) (err error)

HashTreeRootWith ssz hashes the UltrasoundStreamBid object with a hasher

func (*UltrasoundStreamBid) MarshalSSZ added in v1.8.2

func (u *UltrasoundStreamBid) MarshalSSZ() ([]byte, error)

MarshalSSZ ssz marshals the UltrasoundStreamBid object

func (*UltrasoundStreamBid) MarshalSSZTo added in v1.8.2

func (u *UltrasoundStreamBid) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo ssz marshals the UltrasoundStreamBid object to a target array

func (*UltrasoundStreamBid) SizeSSZ added in v1.8.2

func (u *UltrasoundStreamBid) SizeSSZ() (size int)

SizeSSZ returns the ssz encoded size in bytes for the UltrasoundStreamBid object

func (*UltrasoundStreamBid) UnmarshalSSZ added in v1.8.2

func (u *UltrasoundStreamBid) UnmarshalSSZ(buf []byte) error

UnmarshalSSZ ssz unmarshals the UltrasoundStreamBid object

Jump to

Keyboard shortcuts

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