common

package
v0.0.0-...-96daba7 Latest Latest
Warning

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

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

Documentation

Overview

Package common contains various helper functions.

Index

Constants

View Source
const (
	DefaultHTTPHost = "localhost" // Default host interface for the HTTP RPC server
	DefaultHTTPPort = 48132       // Default TCP port for the HTTP RPC server
	DefaultWSHost   = "localhost" // Default host interface for the websocket RPC server
	DefaultWSPort   = 31420       // Default TCP port for the websocket RPC server
	DefaultP2PPort  = 8483
)

Variables

View Source
var TimeoutErr = errors.New("timeout")

Functions

func Bytes2Hex

func Bytes2Hex(d []byte) string

Bytes2Hex returns the hexadecimal encoding of d.

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

CopyBytes returns an exact copy of the provided bytes.

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir is $HOME/viteisbest/

func DefaultHttpEndpoint

func DefaultHttpEndpoint() string

func DefaultIpcFile

func DefaultIpcFile() string

func DefaultWSEndpoint

func DefaultWSEndpoint() string

func FromHex

func FromHex(s string) []byte

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func Go

func Go(fn func())

func GoViteTestDataDir

func GoViteTestDataDir() string

it is the dir in go-vite/testdata

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func Hex2BytesFixed

func Hex2BytesFixed(str string, flen int) []byte

Hex2BytesFixed returns bytes of a specified fixed length flen.

func HomeDir

func HomeDir() string

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

LeftPadBytes zero-pads slice to the left up to length l.

func MakeDefaultLogger

func MakeDefaultLogger(absFilePath string) *lumberjack.Logger

func MockAddress

func MockAddress(i int) types.Address

func MockHash

func MockHash(i int) types.Hash

func MockHashBy

func MockHashBy(i1 int, i int) types.Hash

func RightPadBytes

func RightPadBytes(slice []byte, l int) []byte

RightPadBytes zero-pads slice to the right up to length l.

func SyncMapLen

func SyncMapLen(m *sync.Map) uint64

func ToHex deprecated

func ToHex(b []byte) string

ToHex returns the hex representation of b, prefixed with '0x'. For empty slices, the return value is "0x0".

Deprecated: use hexutil.Encode instead.

Types

type CondTimer

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

func NewCondTimer

func NewCondTimer() *CondTimer

func (*CondTimer) Broadcast

func (self *CondTimer) Broadcast()

func (*CondTimer) Signal

func (self *CondTimer) Signal()

func (*CondTimer) Start

func (self *CondTimer) Start(t time.Duration)

func (*CondTimer) Stop

func (self *CondTimer) Stop()

func (*CondTimer) Wait

func (self *CondTimer) Wait()

type Lifecycle

type Lifecycle interface {
	Init()
	Start()
	Stop()
	GetStatus() int32
}

type LifecycleStatus

type LifecycleStatus struct {
	Status int32 // 0:origin 1: initing 2:inited 3:starting 4:started 5:stopping 6:stopped
}

func (*LifecycleStatus) GetStatus

func (self *LifecycleStatus) GetStatus() int32

func (*LifecycleStatus) PostInit

func (self *LifecycleStatus) PostInit() bool

func (*LifecycleStatus) PostStart

func (self *LifecycleStatus) PostStart() bool

func (*LifecycleStatus) PostStop

func (self *LifecycleStatus) PostStop() bool

func (*LifecycleStatus) PreInit

func (self *LifecycleStatus) PreInit() bool

func (*LifecycleStatus) PreStart

func (self *LifecycleStatus) PreStart() bool

func (*LifecycleStatus) PreStop

func (self *LifecycleStatus) PreStop() bool

func (*LifecycleStatus) Stopped

func (self *LifecycleStatus) Stopped() bool

type NonBlockLock

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

func (*NonBlockLock) Lock

func (self *NonBlockLock) Lock()

func (*NonBlockLock) TryLock

func (self *NonBlockLock) TryLock() bool

func (*NonBlockLock) UnLock

func (self *NonBlockLock) UnLock() bool

type TimeoutCond

type TimeoutCond struct {
	L sync.Locker
	// contains filtered or unexported fields
}

func NewTimeoutCond

func NewTimeoutCond() *TimeoutCond

func (*TimeoutCond) Broadcast

func (self *TimeoutCond) Broadcast()

func (*TimeoutCond) Signal

func (self *TimeoutCond) Signal()

func (*TimeoutCond) Wait

func (self *TimeoutCond) Wait()

func (*TimeoutCond) WaitTimeout

func (self *TimeoutCond) WaitTimeout(t time.Duration) error

type Version

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

func (*Version) Inc

func (self *Version) Inc()

func (*Version) Val

func (self *Version) Val() uint64

Directories

Path Synopsis
db
xleveldb
Package leveldb provides implementation of LevelDB key/value database.
Package leveldb provides implementation of LevelDB key/value database.
xleveldb/cache
Package cache provides interface and implementation of a cache algorithms.
Package cache provides interface and implementation of a cache algorithms.
xleveldb/comparer
Package comparer provides interface and implementation for ordering sets of data.
Package comparer provides interface and implementation for ordering sets of data.
xleveldb/errors
Package errors provides common error types used throughout leveldb.
Package errors provides common error types used throughout leveldb.
xleveldb/filter
Package filter provides interface and implementation of probabilistic data structure.
Package filter provides interface and implementation of probabilistic data structure.
xleveldb/iterator
Package iterator provides interface and implementation to traverse over contents of a database.
Package iterator provides interface and implementation to traverse over contents of a database.
xleveldb/journal
Package journal reads and writes sequences of journals.
Package journal reads and writes sequences of journals.
xleveldb/memdb
Package memdb provides in-memory key/value database implementation.
Package memdb provides in-memory key/value database implementation.
xleveldb/opt
Package opt provides sets of options used by LevelDB.
Package opt provides sets of options used by LevelDB.
xleveldb/storage
Package storage provides storage abstraction for LevelDB.
Package storage provides storage abstraction for LevelDB.
xleveldb/table
Package table allows read and write sorted key/value.
Package table allows read and write sorted key/value.
xleveldb/util
Package util provides utilities used throughout leveldb.
Package util provides utilities used throughout leveldb.
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.
Package math provides integer math utilities.
Package math provides integer math utilities.

Jump to

Keyboard shortcuts

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