common

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxSafeJSInt represents max value which JS support
	// It is used for smartContract fields
	// Our staking repo is written in JS, as are many other clients
	// If we use higher value JS will not be able to parse it
	MaxSafeJSInt = uint64(math.Pow(2, 53) - 2)

	MaxGrpcMsgSize = 16 * 1024 * 1024 // 16MB
)

Functions

func ClampInt64ToInt added in v1.2.1

func ClampInt64ToInt(v int64) int

ClampInt64ToInt returns the int64 value clamped to the range of an int

func ConvertUnmarshalledInt

func ConvertUnmarshalledInt(x interface{}) (int64, error)

func DirectoryExists

func DirectoryExists(directoryPath string) bool

DirectoryExists checks if the directory at the specified path exists

func GetOutboundIP added in v1.2.4

func GetOutboundIP() (net.IP, error)

GetOutboundIP returns the preferred outbound ip of this machine

func GetTerminationSignalCh

func GetTerminationSignalCh() <-chan os.Signal

GetTerminationSignalCh returns a channel to emit signals by ctrl + c

func MaxInt added in v1.2.1

func MaxInt(a, b int) int

MaxInt returns the strictly bigger int number

func MaxUint64 added in v1.2.4

func MaxUint64(a, b uint64) uint64

MaxUint64 returns the strictly bigger number

func MinInt added in v1.2.4

func MinInt(a, b int) int

MinInt returns the strictly lower number(int)

func MinInt64 added in v1.2.4

func MinInt64(a, b int64) int64

MinUint64 returns the strictly lower number

func MinUint64 added in v1.2.4

func MinUint64(a, b uint64) uint64

MinUint64 returns the strictly lower number

func PadLeftOrTrim

func PadLeftOrTrim(bb []byte, size int) []byte

PadLeftOrTrim left-pads the passed in byte array to the specified size, or trims the array if it exceeds the passed in size

func SecureRandInt added in v1.2.4

func SecureRandInt(max int) int

func SecureRandInt64 added in v1.2.4

func SecureRandInt64(max int64) int64

func SetupDataDir

func SetupDataDir(dataDir string, paths []string) error

SetupDataDir sets up the data directory and the corresponding sub-directories

func Substr added in v1.2.4

func Substr(input string, start int, size int) string

Substr returns a substring of the input string

func ToFixedFloat

func ToFixedFloat(num float64, precision int) float64

Types

type JSONNumber

type JSONNumber struct {
	Value uint64
}

JSONNumber is the number represented in decimal or hex in json

func (*JSONNumber) MarshalJSON

func (d *JSONNumber) MarshalJSON() ([]byte, error)

func (*JSONNumber) UnmarshalJSON

func (d *JSONNumber) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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