utils

package
v1.19.8 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: GPL-3.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildRelease string
View Source
var BuildVersion string
View Source
var Buildtime string
View Source
var Config *types.Config

Config is the globally accessible configuration

View Source
var ETH *big.Int = big.NewInt(0).Mul(GWEI, GWEI)
View Source
var GWEI *big.Int = big.NewInt(1000000000)

Functions

func AlternateUint256ToUint64 added in v1.16.0

func AlternateUint256ToUint64(bytes [32]byte) uint64

AlternateUint256ToUint64 converts a [32]byte representation of a uint256 to a uint64 using big.Int

func BitAtVector

func BitAtVector(b []byte, i int) bool

func BitAtVectorReversed

func BitAtVectorReversed(b []byte, i int) bool

func CalculatePercentage added in v1.16.0

func CalculatePercentage(value uint64, total uint64) float64

CalculatePercentage calculates the percentage of a value from a total

func ConvertPeerIDStringToEnodeID added in v1.12.1

func ConvertPeerIDStringToEnodeID(pidStr string) (enode.ID, error)

ConvertPeerIDStringToEnodeID converts a libp2p peer ID string to an enode.ID.

func CustodyColumnSubnets added in v1.12.1

func CustodyColumnSubnets(nodeId enode.ID, custodySubnetCount uint64, dataColumnSidecarSubnetCount uint64) (map[uint64]bool, error)

func CustodyColumnSubnetsSlice added in v1.12.1

func CustodyColumnSubnetsSlice(nodeId enode.ID, custodySubnetCount uint64, dataColumnSidecarSubnetCount uint64) ([]uint64, error)

func CustodyColumns added in v1.12.1

func CustodyColumns(nodeId enode.ID, custodySubnetCount uint64, numberOfColumns uint64, dataColumnSidecarSubnetCount uint64) (map[uint64]bool, error)

CustodyColumns computes the columns the node should custody. https://github.com/ethereum/consensus-specs/blob/dev/specs/fulu/das-core.md#helper-functions

func CustodyColumnsSlice added in v1.12.1

func CustodyColumnsSlice(nodeId enode.ID, custodySubnetCount uint64, numberOfColumns uint64, dataColumnSidecarSubnetCount uint64) ([]uint64, error)

func DecodeENR added in v1.11.2

func DecodeENR(raw string) (*enr.Record, error)

func DecodeUint64BitfieldFromQuery added in v1.19.6

func DecodeUint64BitfieldFromQuery(query string, fieldName string) uint64

func FindMatchingIndices added in v1.15.0

func FindMatchingIndices(a, b []uint64) []uint64

FindMatchingIndices returns indices that appear in both slices assumes both slices contain uint64 values

func FormatAddCommas

func FormatAddCommas(n uint64) template.HTML

func FormatAddCommasFormatted added in v1.14.0

func FormatAddCommasFormatted(num float64, precision uint) template.HTML

func FormatAmount

func FormatAmount(amount *big.Int, unit string, digits int) template.HTML

func FormatAmountFormatted

func FormatAmountFormatted(amount *big.Int, unit string, digits int, maxPreCommaDigitsBeforeTrim int, fullAmountTooltip bool, smallUnit bool, newLineForUnit bool) template.HTML

func FormatBaseFee added in v1.17.0

func FormatBaseFee(weiValue uint64) template.HTML

func FormatBigAmount

func FormatBigAmount(amount *hexutil.Big, unit string, digits int) template.HTML

func FormatBigNumberAddCommasFormatted added in v1.14.0

func FormatBigNumberAddCommasFormatted(val hexutil.Big, precision uint) template.HTML

func FormatBitlist

func FormatBitlist(b []byte, v []types.NamedValidator) template.HTML

func FormatBlobFeeDifference added in v1.19.4

func FormatBlobFeeDifference(eip7918Value, originalValue uint64) template.HTML

func FormatByteAmount added in v1.16.0

func FormatByteAmount(bytes uint64) template.HTML

FormatByteAmount converts a byte count to a human-readable string with appropriate unit (B, kB, MB, GB)

func FormatBytesAmount

func FormatBytesAmount(amount []byte, unit string, digits int) template.HTML

func FormatETH

func FormatETH(num string) string

func FormatETHAddCommasFromGwei

func FormatETHAddCommasFromGwei(gwei uint64) template.HTML

func FormatETHFromGwei

func FormatETHFromGwei(gwei uint64) string

func FormatETHFromGweiShort

func FormatETHFromGweiShort(gwei uint64) string

func FormatEthAddress

func FormatEthAddress(address []byte) template.HTML
func FormatEthAddressLink(address []byte) template.HTML
func FormatEthBlockHashLink(blockHash []byte) template.HTML
func FormatEthBlockLink(blockNum uint64) template.HTML
func FormatEthTransactionLink(hash []byte, width uint64) template.HTML

func FormatFloat

func FormatFloat(num float64, precision int) string

func FormatFullEthFromGwei added in v1.16.0

func FormatFullEthFromGwei(gwei uint64) string

func FormatGraffiti

func FormatGraffiti(graffiti []byte) template.HTML

func FormatGraffitiString

func FormatGraffitiString(graffiti string) string

FormatGraffitiString formats (and escapes) the graffiti

func FormatGweiValue added in v1.16.0

func FormatGweiValue(val uint64) string

FormatGweiValue formats a gas value in Gwei

func FormatParticipation

func FormatParticipation(v float64) template.HTML

func FormatRecentTimeShort

func FormatRecentTimeShort(ts time.Time) template.HTML

func FormatRecvDelay added in v1.17.0

func FormatRecvDelay(delay int32) template.HTML

func FormatSlashedValidator

func FormatSlashedValidator(index uint64, name string) template.HTML

func FormatTransactionValue added in v1.19.4

func FormatTransactionValue(ethValue float64) template.HTML

func FormatValidator

func FormatValidator(index uint64, name string) template.HTML

func FormatValidatorNameWithIndex added in v1.13.0

func FormatValidatorNameWithIndex(index uint64, name string) template.HTML

func FormatValidatorWithIndex

func FormatValidatorWithIndex(index uint64, name string) template.HTML

func FormatWithdawalCredentials

func FormatWithdawalCredentials(hash []byte) template.HTML

func GetBaseFeeAsUint64 added in v1.16.0

func GetBaseFeeAsUint64(baseFee interface{}) uint64

GetBaseFeeAsUint64 is a generic function that converts any BaseFeePerGas type to uint64 It handles both [32]byte and objects with Uint64() method

func GetExplorerVersion

func GetExplorerVersion() string

func GetFrontendRPCUrl added in v1.19.1

func GetFrontendRPCUrl() string

GetFrontendRPCUrl returns the appropriate RPC URL for the frontend. If RPC proxy is enabled, it returns the local proxy endpoint. Otherwise, it returns the configured public RPC URL.

func GetKeyValuesFromENR added in v1.11.2

func GetKeyValuesFromENR(r *enr.Record) map[string]interface{}

func GetKeyValuesFromENRFiltered added in v1.18.2

func GetKeyValuesFromENRFiltered(r *enr.Record) map[string]interface{}

func GetNodeIDFromENR added in v1.11.2

func GetNodeIDFromENR(r *enr.Record) enode.ID

func GetRedactedUrl

func GetRedactedUrl(requrl string) string

func GetTemplateFuncs

func GetTemplateFuncs() template.FuncMap

GetTemplateFuncs will get the template functions

func GraffitiToString

func GraffitiToString(graffiti []byte) string

func HandleSubroutinePanic

func HandleSubroutinePanic(identifier string, restartFn func())

func IncludeHTML

func IncludeHTML(path string) template.HTML

IncludeHTML adds html to the page

func IncludeJSON added in v1.12.1

func IncludeJSON(obj any, escapeHTML bool) template.HTML

IncludeJSON adds json to the page

func LoadGenesisFromPathOrURL added in v1.19.0

func LoadGenesisFromPathOrURL(pathOrURL string) (*core.Genesis, error)

LoadGenesisFromPathOrURL loads a genesis config from either a local file path or HTTP/HTTPS URL

func LogError

func LogError(err error, errorMsg interface{}, callerSkip int, additionalInfos ...map[string]interface{})

LogError logs an error with callstack info that skips callerSkip many levels with arbitrarily many additional infos. callerSkip equal to 0 gives you info directly where LogError is called.

func LogFatal

func LogFatal(err error, errorMsg interface{}, callerSkip int, additionalInfos ...map[string]interface{})

LogFatal logs a fatal error with callstack info that skips callerSkip many levels with arbitrarily many additional infos. callerSkip equal to 0 gives you info directly where LogFatal is called.

func MustParseHex

func MustParseHex(hexString string) []byte

MustParseHex will parse a string into hex

func ParseSpecMap added in v1.19.3

func ParseSpecMap(data map[string]any) map[string]any

func ReadConfig

func ReadConfig(cfg *types.Config, path string) error

ReadConfig will process a configuration

func SliceContains

func SliceContains(list []string, target string) bool

sliceContains reports whether the provided string is present in the given slice of strings.

func SyncCommitteeParticipation

func SyncCommitteeParticipation(bits []byte, syncCommitteeSize uint64) float64

func Uint256ToUint64 added in v1.16.0

func Uint256ToUint64(bytes [32]byte) uint64

Uint256ToUint64 converts a [32]byte representation of a uint256 to a uint64

func WaitForCtrlC

func WaitForCtrlC()

WaitForCtrlC will block/wait until a control-c is pressed

Types

type Dispatcher added in v1.17.0

type Dispatcher[T interface{}] struct {
	// contains filtered or unexported fields
}

func (*Dispatcher[T]) Fire added in v1.17.0

func (d *Dispatcher[T]) Fire(data T)

func (*Dispatcher[T]) Subscribe added in v1.17.0

func (d *Dispatcher[T]) Subscribe(capacity int, blocking bool) *Subscription[T]

func (*Dispatcher[T]) Unsubscribe added in v1.17.0

func (d *Dispatcher[T]) Unsubscribe(subscription *Subscription[T])

type LogWriter

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

func InitLogger

func InitLogger() (*LogWriter, logrus.FieldLogger)

func (*LogWriter) Dispose

func (logWriter *LogWriter) Dispose()

type LogWriterHook

type LogWriterHook struct {
	Writer    io.Writer
	LogLevels []logrus.Level
}

WriterHook is a hook that writes logs of specified LogLevels to specified Writer

func (*LogWriterHook) Fire

func (hook *LogWriterHook) Fire(entry *logrus.Entry) error

Fire will be called when some logging function is called with current hook It will format log entry to string and write it to appropriate writer

func (*LogWriterHook) Levels

func (hook *LogWriterHook) Levels() []logrus.Level

type Subscription added in v1.17.0

type Subscription[T interface{}] struct {
	// contains filtered or unexported fields
}

func (*Subscription[T]) Channel added in v1.17.0

func (s *Subscription[T]) Channel() <-chan T

func (*Subscription[T]) Unsubscribe added in v1.17.0

func (s *Subscription[T]) Unsubscribe()

Jump to

Keyboard shortcuts

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