utils

package
v0.0.0-...-3f8eaf4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: GPL-3.0 Imports: 20 Imported by: 10

Documentation

Overview

Package utils provides various tools such as min/max and other usful things

Index

Constants

View Source
const EarliestEvmTs = 1438269971

EarliestEvmTs - The timestamp of the first Ethereum block in summer 2015 was this value. Since Ethereum was the first EVM based blockchain, all other EVM based block chains have timestamps after this. We can use this fact to distinguish between block numbers and timestamps on the command line (any number in a block range smaller than this is a blockNumber, anything larger than this is a timestamp). This breaks when the block number gets larger than 1,4 billion, which may happen when the chain shards, but not until then.

View Source
const NOPOS = uint64(^uint64(0))
View Source
const NOPOSI = int64(0xdeadbeef)

Variables

This section is empty.

Functions

func FormattedCode

func FormattedCode(verbose bool, code string) string

func FormattedDate

func FormattedDate(ts int64) string

func FormattedHash

func FormattedHash(verbose bool, code string) string

func FormattedValue

func FormattedValue(in big.Int, asEther bool, decimals int) string

func GetFields

func GetFields(t *reflect.Type, format string, header bool) (fields []string, sep string, quote string)

func GetTestChain

func GetTestChain() string

GetTestChain does not get customized per chain. We can only test against mainnet currently

func IsClientErigon

func IsClientErigon(version string) bool

IsClientErigon checks if `version` looks like Erigon

func IsServerWriter

func IsServerWriter(w io.Writer) bool

IsServerWriter tries to cast `w` into `http.ResponseWriter` and returns true if the cast was successful

func IsTerminal

func IsTerminal() bool

func IterateOverMap

func IterateOverMap[Key comparable, Value any](ctx context.Context, errorChan chan error, target map[Key]Value, step stepFunc[Key, Value])

IterateOverMap distributes batches of `target` items to a pool of goroutines which execute `step` for every `target` item. Use benchmarks to make sure that concurrent iteration is faster than synchronous one.

func LowerIfHex

func LowerIfHex(addr string) string

func MakeFirstLowerCase

func MakeFirstLowerCase(s string) string

func MakeFirstUpperCase

func MakeFirstUpperCase(s string) string

func Max

func Max[T int | float64 | uint32 | int64 | uint64](x, y T) T

Max calculates the max between two unsigned integers (golang has no such function)

func Min

func Min[T int | float64 | uint32 | int64 | uint64](x, y T) T

Min calculates the minimum between two unsigned integers (golang has no such function)

func MustParseInt

func MustParseInt(input any) (result int64)

func MustParseUint

func MustParseUint(input any) (result uint64)

func OpenBrowser

func OpenBrowser(url string)

func PadLeft

func PadLeft(str string, totalLen int, pad rune) string

func PadNum

func PadNum(n int, totalLen int) string

func PadRight

func PadRight(str string, totalLen int, pad rune) string

func PidExists

func PidExists(pid int64) (bool, error)

func PointerOf

func PointerOf[T any](value T) *T

func Str_2_BigInt

func Str_2_BigInt(str string) big.Int

func StripComments

func StripComments(cmd string) string

func System

func System(cmd string) int

func Trace

func Trace()

Types

This section is empty.

Jump to

Keyboard shortcuts

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