util

package
v0.2.3-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIntegerOverflow defines integer overflow
	ErrIntegerOverflow = errors.New("integer overflow")
)
View Source
var (
	// ErrNotInSecondarySPs define the specified sp does not exist error.
	ErrNotInSecondarySPs = errors.New("target sp is not in the gvg secondary sp list")
)
View Source
var TomlSettings = toml.Config{
	NormFieldName: func(rt reflect.Type, key string) string {
		return key
	},
	FieldToKey: func(rt reflect.Type, field string) string {
		return field
	},
	MissingField: func(rt reflect.Type, field string) error {
		link := ""
		if unicode.IsUpper(rune(rt.Name()[0])) && rt.PkgPath() != "main" {
			link = fmt.Sprintf(", see https://pkg.go.dev/%s#%s for available fields", rt.PkgPath(), rt.Name())
		}
		_, _ = fmt.Fprintf(os.Stderr, "field '%s' is not defined in %s%s\n", field, rt.String(), link)
		return nil
	},
}

TomlSettings - These settings ensure that TOML keys use the same names as Go struct fields.

Functions

func BoolToInt

func BoolToInt(b bool) int

BoolToInt converts bool to int

func BytesSliceToString

func BytesSliceToString(bytes [][]byte) string

BytesSliceToString is used to serialize

func GenerateRequestID

func GenerateRequestID() string

GenerateRequestID is used to generate random requestID.

func GetIPFromGRPCContext

func GetIPFromGRPCContext(ctx context.Context) net.IP

GetIPFromGRPCContext returns a IP from grpc client

func GetRandomBucketName added in v0.2.2

func GetRandomBucketName() string

GetRandomBucketName generate random bucket name.

func GetRandomGroupName added in v0.2.2

func GetRandomGroupName() string

GetRandomGroupName generate random group name.

func GetRandomObjectName added in v0.2.2

func GetRandomObjectName() string

GetRandomObjectName generate random object name.

func GetSecondarySPIndexFromGVG added in v0.2.3

func GetSecondarySPIndexFromGVG(gvg *virtualgrouptypes.GlobalVirtualGroup, spID uint32) (int32, error)

GetSecondarySPIndexFromGVG returns secondary sp index in the secondary sp list.

func JoinWithComma

func JoinWithComma(slice []string) string

JoinWithComma converts string slice to one string with comma

func RandHexKey added in v0.2.2

func RandHexKey() string

func RandInt64 added in v0.2.2

func RandInt64(min, max int64) int64

RandInt64 generate random int64 between min and max

func RandomNum added in v0.2.2

func RandomNum(n, scope int) int

func RandomString added in v0.2.2

func RandomString(n int) string

func RandomStringToLower added in v0.2.2

func RandomStringToLower(n int) string

func RandomStringToUpper added in v0.2.2

func RandomStringToUpper(n int) string

func SplitByComma

func SplitByComma(str string) []string

SplitByComma splits string by comma

func StringArrayToUint32Slice added in v0.2.3

func StringArrayToUint32Slice(arr pq.StringArray) ([]uint32, error)

func StringToBool

func StringToBool(str string) (bool, error)

StringToBool coverts string to bool

func StringToBytesSlice

func StringToBytesSlice(str string) ([][]byte, error)

StringToBytesSlice is used to deserialize

func StringToInt32

func StringToInt32(str string) (int32, error)

StringToInt32 converts string to int32

func StringToInt64

func StringToInt64(str string) (int64, error)

StringToInt64 converts string to int64

func StringToUint32

func StringToUint32(str string) (uint32, error)

StringToUint32 coverts string to uint32

func StringToUint64

func StringToUint64(str string) (uint64, error)

StringToUint64 converts string to uint64

func TotalStakingStoreSizeOfGVG added in v0.2.3

func TotalStakingStoreSizeOfGVG(gvg *virtualgrouptypes.GlobalVirtualGroup, stakingPerBytes sdkmath.Int) uint64

TotalStakingStoreSizeOfGVG calculates the global virtual group total staking storage size

func Uint32ToString

func Uint32ToString(u uint32) string

Uint32ToString converts uint32 to string

func Uint64ToString

func Uint64ToString(u uint64) string

Uint64ToString coverts uint64 to string

func ValidateAndGetSPIndexWithinGVGSecondarySPs added in v0.2.3

func ValidateAndGetSPIndexWithinGVGSecondarySPs(ctx context.Context, client *gfspclient.GfSpClient, selfSpID uint32,
	bucketID uint64, lvgID uint32) (int, bool, error)

ValidateAndGetSPIndexWithinGVGSecondarySPs return whether current sp is one of the object gvg's secondary sp and its index within GVG(if is)

Types

This section is empty.

Directories

Path Synopsis
rpc

Jump to

Keyboard shortcuts

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