common

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 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 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 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 added in v1.3.2

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

func NewTimeoutCond added in v1.3.2

func NewTimeoutCond() *TimeoutCond

func (*TimeoutCond) Broadcast added in v1.3.2

func (self *TimeoutCond) Broadcast()

func (*TimeoutCond) Signal added in v1.3.2

func (self *TimeoutCond) Signal()

func (*TimeoutCond) Wait added in v1.3.2

func (self *TimeoutCond) Wait()

func (*TimeoutCond) WaitTimeout added in v1.3.2

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

Directories

Path Synopsis
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