common

package
v0.0.3-chain-bsopt Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: GPL-3.0 Imports: 8 Imported by: 48

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

This section is empty.

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 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 MockAddress

func MockAddress(i int) types.Address

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) TryLock

func (self *NonBlockLock) TryLock() bool

func (*NonBlockLock) UnLock

func (self *NonBlockLock) UnLock() bool

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