utils

package
v1.7.11 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBytes added in v1.6.11

func CopyBytes(b []byte) []byte

CopyBytes returns a copy of the provided byte slice. If nil is provided, nil will be returned.

func IsSorted2DBytes added in v1.6.11

func IsSorted2DBytes(arr [][]byte) bool

IsSorted2DBytes returns true iff [arr] is sorted

func IsSortedAndUnique

func IsSortedAndUnique(data sort.Interface) bool

IsSortedAndUnique returns true if the elements in the data are unique and sorted.

func IsSortedAndUniqueUint32

func IsSortedAndUniqueUint32(arr []uint32) bool

IsSortedAndUniqueUint32 returns true if the array of uint32s are sorted and unique

func IsSortedAndUniqueUint64 added in v1.6.11

func IsSortedAndUniqueUint64(u64 []uint64) bool

IsSortedAndUniqueUint64 returns true if the array of uint64s are sorted and unique

func RandomBytes added in v1.6.11

func RandomBytes(n int) []byte

RandomBytes returns a slice of n random bytes Intended for use in testing

func Sort2DBytes added in v1.6.11

func Sort2DBytes(arr [][]byte)

Sort2DBytes sorts a 2D byte array Each byte array is not sorted internally; the byte arrays are sorted relative to another.

func SortUint32

func SortUint32(u32 []uint32)

SortUint32 sorts an uint32 array

func SortUint64 added in v1.6.11

func SortUint64(u64 []uint64)

SortUint64 sorts an uint64 array

Types

type AtomicBool added in v1.6.11

type AtomicBool struct {
	// contains filtered or unexported fields
}

func (*AtomicBool) GetValue added in v1.6.11

func (a *AtomicBool) GetValue() bool

func (*AtomicBool) SetValue added in v1.6.11

func (a *AtomicBool) SetValue(b bool)

type AtomicInterface added in v1.6.11

type AtomicInterface struct {
	// contains filtered or unexported fields
}

func NewAtomicInterface added in v1.6.11

func NewAtomicInterface(v interface{}) *AtomicInterface

func (*AtomicInterface) GetValue added in v1.6.11

func (a *AtomicInterface) GetValue() interface{}

func (*AtomicInterface) SetValue added in v1.6.11

func (a *AtomicInterface) SetValue(v interface{})

type DynamicIPDesc added in v1.6.11

type DynamicIPDesc struct {
	*IPDescContainer
}

func NewDynamicIPDesc added in v1.6.11

func NewDynamicIPDesc(ip net.IP, port uint16) DynamicIPDesc

func (*DynamicIPDesc) IP added in v1.6.11

func (i *DynamicIPDesc) IP() IPDesc

func (*DynamicIPDesc) Update added in v1.6.11

func (i *DynamicIPDesc) Update(ip IPDesc)

func (*DynamicIPDesc) UpdateIP added in v1.6.11

func (i *DynamicIPDesc) UpdateIP(ip net.IP)

func (*DynamicIPDesc) UpdatePort added in v1.6.11

func (i *DynamicIPDesc) UpdatePort(port uint16)

type IPCertDesc added in v1.6.11

type IPCertDesc struct {
	Cert      *x509.Certificate
	IPDesc    IPDesc
	Time      uint64
	Signature []byte
}

type IPDesc

type IPDesc struct {
	IP   net.IP `json:"ip"`
	Port uint16 `json:"port"`
}

func ToIPDesc

func ToIPDesc(str string) (IPDesc, error)

func (IPDesc) Equal

func (ipDesc IPDesc) Equal(otherIPDesc IPDesc) bool

func (IPDesc) IsPrivate

func (ipDesc IPDesc) IsPrivate() bool

IsPrivate attempts to decide if the ip address in this descriptor is a local ip address. This function was taken from: https://stackoverflow.com/a/50825191/3478466

func (IPDesc) IsZero

func (ipDesc IPDesc) IsZero() bool

IsZero returns if the IP or port is zeroed out

func (IPDesc) PortString

func (ipDesc IPDesc) PortString() string

func (IPDesc) String

func (ipDesc IPDesc) String() string

type IPDescContainer added in v1.6.11

type IPDescContainer struct {
	*IPDesc
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package sharding is a generated GoMock package.
Package sharding is a generated GoMock package.
Package logging is a generated GoMock package.
Package logging is a generated GoMock package.

Jump to

Keyboard shortcuts

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