util

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const GenesisTime uint64 = 1681971084

GenesisTime min timestamp Thursday, April 20, 2023 6:11:24 AM GMT+00:00

Variables

This section is empty.

Functions

func BytesToUint256 added in v0.1.3

func BytesToUint256(b []byte) *uint256.Int

func BytesToUint32 added in v0.2.0

func BytesToUint32(b []byte) uint32

func BytesToUint64 added in v0.1.1

func BytesToUint64(b []byte) uint64

func EncodeToJsonHelper added in v0.2.0

func EncodeToJsonHelper(arg interface{}) string

EncodeToJsonHelper encodes to argument to json and returns it as string, on encode error return error message as string

func FileExists

func FileExists(path string) bool

func GetFileSize added in v0.1.1

func GetFileSize(filepath string) (int64, error)

func IsBitSet

func IsBitSet(bytes []byte, bitPosition int) bool

func IsValidURI added in v0.1.1

func IsValidURI(u string) bool

func MakeTimestamp added in v0.2.0

func MakeTimestamp() uint64

MakeTimestamp returns timestamp in seconds from epoch

func Max added in v0.2.0

func Max[T constraints.Ordered](a, b T) T

func Min added in v0.1.1

func Min[T constraints.Ordered](a, b T) T

func ReadJsonFile

func ReadJsonFile[T any](path string, res *T) (*T, error)

func ShuffleSliceCopy

func ShuffleSliceCopy[T any](src []T) (dst []T)

func Uint256ToBytes added in v0.1.1

func Uint256ToBytes(i *uint256.Int) []byte

func Uint32ToBytes added in v0.1.1

func Uint32ToBytes(i uint32) []byte

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

func Uint64ToBytes32 added in v0.2.0

func Uint64ToBytes32(n uint64) []byte

func WriteCBORError added in v0.2.0

func WriteCBORError(w http.ResponseWriter, e error, code int)

WriteCBORError replies to the request with the specified error message and HTTP code. It does not otherwise end the request; the caller should ensure no further writes are done to w.

func WriteCBORResponse added in v0.2.0

func WriteCBORResponse(w http.ResponseWriter, response any, statusCode int)

WriteCBORResponse replies to the request with the given response and HTTP code.

func WriteDebugJsonLog

func WriteDebugJsonLog(l log.Logger, m string, arg interface{})

func WriteJsonFile

func WriteJsonFile[T any](path string, obj *T) error

func WriteTraceJsonLog added in v0.2.0

func WriteTraceJsonLog(l log.Logger, m string, arg interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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