util

package
v0.0.0-...-07d62d3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Context = "UTIL"

Context to use when logging

Variables

This section is empty.

Functions

func GetB16Hash

func GetB16Hash(data []byte) string

GetB16Hash returns the sha1 hash of the byte array encoded to base16

func GetEnvOrDefault

func GetEnvOrDefault(name string, defaultValue string) string

GetEnvOrDefault returns the env if it is set, otherwise the default value

func GetEnvOrFatal

func GetEnvOrFatal(name string) string

GetEnvOrFatal if the env is not set or set to an empty string

func GetWorkerId

func GetWorkerId() string

GetWorkerId by using os.Getenv again.

func MaybeRatToFloat

func MaybeRatToFloat(rat *big.Rat) float64

converts a big.Rat to a float, returning 0 if the rat is nil

func PickEnvOrFatal

func PickEnvOrFatal(envName string) (variable string)

PickEnvOrFatal from a list of inputs provided separated by , - picking one at random each time

func RandomIntegers

func RandomIntegers(amount int, min, max uint32) (numbers []uint32)

generateRandomIntegers gated between min and max, inclusive on both ends, doing some coercion internally to use crypto/rand and assuming that the uint32 requirement in the arguments prevent any size-of-int issues

func RandomString

func RandomString(length int) string

RandomString generated by creating a buffer of length / 2, filling it up with randomness then returning the base16 encoded form of it.

func UintMin

func UintMin(left, right int) int

func UnixStringToTime

func UnixStringToTime(unixString string) (*time.Time, error)

UnixStringToTime parses a string containing a unix timestamp

Types

type TokenDetailsBase

type TokenDetailsBase struct {
	TokenAddress  string
	TokenDecimals *big.Rat
	TokenName     string

	// Extras is anything off to the right, in it's string format.
	Extras []string
}

TokenDetailsBase for the minimum token information, used currently by microservice-common-count-wins. TokenDecimals is in its exponential form (ie, 1e18)

func GetTokensListBase

func GetTokensListBase(tokensList_ string) []TokenDetailsBase

GetTokensListBase starting with the address, token name and decimals

func NewTokenDetailsBase

func NewTokenDetailsBase(address, name string, decimals int, extras ...string) TokenDetailsBase

NewTokenDetailsBase with the name and number to turn into an exponential number (ie if given 10, will go 1e10)

Jump to

Keyboard shortcuts

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