common

package
v3.8.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ACCOUNT_NAME_REGEXP string = "^[a-z][a-z0-9.-]{2,20}$"
View Source
const CONTRACT_NAME_REGEXP string = "^[a-z][a-z0-9]{2,9}$"

ACCOUNT_NAME_REGEXP define account name format

View Source
const EX_CONTRACT_NAME_REGEXP string = "^[a-z][a-z0-9]{2,9}@[a-z][a-z0-9.-]{2,20}$"
View Source
const (
	//HashLength the length of hash bytes
	HashLength = 32
)
View Source
const (
	// MaxNameLength define max account name length
	MaxNameLength int = 21
)

Variables

Functions

func BytesToHex

func BytesToHex(d []byte) string

BytesToHex hex data to string

func CheckAccountNameContent

func CheckAccountNameContent(name string) bool

func CheckContractNameContent

func CheckContractNameContent(name string) bool

func CheckExContractNameContent

func CheckExContractNameContent(name string) bool

func Elapsed

func Elapsed(t uint64) uint64

Elapsed calculate elapsed Millisecond

func EmptyHash

func EmptyHash(h Hash) bool

EmptyHash chech hash data

func Filter

func Filter(sources []string, filters []string) []string

Filter filter out and return the rest

func HexStringToBytes

func HexStringToBytes(s string) []byte

HexStringToBytes hex string to bytes

func HexToBytes

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

HexToBytes hex string to bytes

func MaxUint128

func MaxUint128() *big.Int

MaxUint128 return max value of 128 bit

func MaxUint256

func MaxUint256() *big.Int

MaxUint256 return max value of 128 bit

func MeasureStart

func MeasureStart() uint64

MeasureStart current monotonic clock time use to measure time

func MicroElapse

func MicroElapse(t uint64) uint64

MicroElapse calculate elapsed Microsecond

func MicrosecondsAddToSec

func MicrosecondsAddToSec(src uint64, des uint64) uint64

MicrosecondsAddToSec add seconds

func NanoElapse

func NanoElapse(t uint64) uint64

NanoElapse calculate elapsed Nanosecond

func NanoToMicroSec

func NanoToMicroSec(src uint64) uint64

NanoToMicroSec convert nanosecond to microsecond

func Now

func Now() uint64

Now current system time seconds

func NowToMicroseconds

func NowToMicroseconds() uint64

NowToMicroseconds return microseconds of now

func NowToSeconds

func NowToSeconds() uint64

NowToSeconds return seconds of now

func NowToSlotSec

func NowToSlotSec(current time.Time, loopMicroSec uint64) uint64

NowToSlotSec convert now seconds to slot second

func NumberToBytes

func NumberToBytes(num interface{}, bits int) []byte

NumberToBytes number code covert to bytes

func ToMicroseconds

func ToMicroseconds(current time.Time) uint64

ToMicroseconds current time to micro second

func ToMilliseconds

func ToMilliseconds(m Microsecond) uint64

ToMilliseconds micro second to milli second

func ToNanoseconds

func ToNanoseconds(current time.Time) uint64

ToNanoseconds return nanoseconds of now

func ToSeconds

func ToSeconds(m Microsecond) uint64

ToSeconds micro second to second

Types

type Hash

type Hash [HashLength]byte

Hash the hash data

func BytesToHash

func BytesToHash(b []byte) Hash

BytesToHash set hash data

func ComputeMerkleRootHash

func ComputeMerkleRootHash(hs []Hash) Hash

ComputeMerkleRootHash create a merkle hash tree and return root hash

func DoubleSha256

func DoubleSha256(data []byte) Hash

DoubleSha256 do sha256 twice

func HexToHash

func HexToHash(s string) Hash

HexToHash hex hash string to hash data

func Sha256

func Sha256(data []byte) Hash

Sha256 do sha256

func StringToHash

func StringToHash(s string) Hash

StringToHash hash string to hash data

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes get hash data

func (*Hash) Label

func (h *Hash) Label() uint32

Label calc lable from hash data

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

SetBytes set hash data from bytes

func (*Hash) SetString

func (h *Hash) SetString(s string)

SetString set hash data from string

func (Hash) ToHexString

func (h Hash) ToHexString() string

ToHexString hash data to hex string

func (Hash) ToString

func (h Hash) ToString() string

ToString hash data to string

type MTNode

type MTNode struct {
	Hash Hash
}

MTNode merkle hash tree node

type MerkleHashTree

type MerkleHashTree struct {
	Root *MTNode
}

MerkleHashTree merkle hash tree

func CreateMerkleTree

func CreateMerkleTree(hs []Hash) *MerkleHashTree

CreateMerkleTree create a merkle hash tree

type Microsecond

type Microsecond struct {
	Count uint64
}

Microsecond micro second type

func MilliSecToMicro

func MilliSecToMicro(m uint64) Microsecond

MilliSecToMicro milli second to micro second

func SecondsToMicro

func SecondsToMicro(s uint64) Microsecond

SecondsToMicro second to micro second

type NameType

type NameType uint
const (
	NameTypeAccount    NameType = 1
	NameTypeExContract NameType = 2
	NameTypeUnknown    NameType = 3
)

func AnalyzeName

func AnalyzeName(name string) (NameType, string)

type Queue

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

func NewQueue

func NewQueue() *Queue

func (*Queue) Length

func (q *Queue) Length() int

func (*Queue) Pop

func (q *Queue) Pop() interface{}

func (*Queue) Push

func (q *Queue) Push(data interface{})

Directories

Path Synopsis
Package types is definition of common type * file description: transaction * @Author: Gong Zibin * @Date: 2017-12-07 * @Last Modified by: * @Last Modified time:
Package types is definition of common type * file description: transaction * @Author: Gong Zibin * @Date: 2017-12-07 * @Last Modified by: * @Last Modified time:

Jump to

Keyboard shortcuts

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