Documentation ¶
Overview ¶
Package common contains various helper functions.
Index ¶
- Constants
- func Bytes2Hex(d []byte) string
- func Bytes2Uint(d []byte) uint64
- func CopyBytes(b []byte) (copiedBytes []byte)
- func FromHex(s string) []byte
- func GetLogger(namespace string) *logging.Logger
- func Hex(b []byte) []byte
- func Hex2Bytes(str string) []byte
- func Hex2BytesFixed(str string, flen int) []byte
- func LeftPadBytes(slice []byte, l int) []byte
- func RightPadBytes(slice []byte, l int) []byte
- func Uint2Bytes(v uint64) []byte
- type Address
- func BigToAddress(b *big.Int) Address
- func BytesToAddress(b []byte) Address
- func CreateAddress(addr Address, nonce uint64) Address
- func GenAddrByPrivkey(key crypto.PrivKey) (Address, error)
- func GenAddrByPubkey(key crypto.PubKey) (Address, error)
- func HashToAddr(hash Hash) Address
- func HexToAddress(d string) Address
- type Config
- func (c *Config) Get(key string) interface{}
- func (c *Config) GetBool(key string) bool
- func (c *Config) GetDuration(key string) time.Duration
- func (c *Config) GetInt(key string) int
- func (c *Config) GetInt64(key string) int64
- func (c *Config) GetSlice(key string) []string
- func (c *Config) GetString(key string) string
- type Hash
- type Logger
- type LoggerMgr
- type Protocol
Constants ¶
View Source
const ( MAX_GAS_LIMIT = "max_gas_limit" MAX_EXTRA_LENGTH = "max_extra_length" MAX_BLOCK_NUM = "max_block_num" )
View Source
const ( // P2P Message Type OkMsg = "OkMsg" RouteSyncReq = "RouteSyncReq" RouteSyncResp = "RouteSyncResp" ConsensusMsg = "ConsensusMsg" ConsensusPeerMsg = "ConsensusPeerMsg" ProposeBlockMsg = "ProposeBlockMsg" ReadyBlockMsg = "ReadyBlockMsg" NewTxMsg = "NewTxMsg" // Consensus Type SoloEngine = "solo" PowEngine = "pow" VrfBftEngine = "vrf_bft" DposBftEngine = "dpos_bft" /* ---- Configuration field ------ */ // consensus EngineName = "consensus.engine" IsMiner = "consensus.miner" ConsensusPrivKey = "consensus.private_key" BlockGasLimit = "consensus.block_gas_limit" Difficulty = "consensus.difficulty" ExtraData = "consensus.extra_data" // P2P RouteFilePath = "p2p.route_file_path" Port = "p2p.port" NetPrivKey = "p2p.private_key" Seeds = "p2p.seeds" MaxPeers = "p2p.max_peers" // VM VMType = "vm.type" // Transaction Pool MaxTxSize = "txpool.max_tx_size" PriceBump = "txpool.price_bump" // percent BatchTimeout = "txpool.batch_timeout" // ms BatchCapacity = "txpool.batch_capacity" // transaction // Block Pool MaxBlockSize = "blockpool.max_block_size" )
View Source
const ( HashLength = 32 AddressLength = 20 )
Variables ¶
This section is empty.
Functions ¶
func Bytes2Uint ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func Hex2BytesFixed ¶
Hex2BytesFixed returns bytes of a specified fixed length flen.
func LeftPadBytes ¶
LeftPadBytes zero-pads slice to the left up to length l.
func RightPadBytes ¶
RightPadBytes zero-pads slice to the right up to length l.
func Uint2Bytes ¶
Types ¶
type Address ¶
type Address [AddressLength]byte
func BigToAddress ¶
func BytesToAddress ¶
func CreateAddress ¶
func GenAddrByPrivkey ¶
Generate address by private key
func GenAddrByPubkey ¶
Generate address by public key
func HashToAddr ¶
func HexToAddress ¶
Decode address in hex format to common.Address
type Hash ¶
type Hash [HashLength]byte
func BigToHash ¶
BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.
func BytesToHash ¶
func DecodeHash ¶
Decode hash string with "0x...." format to Hash type
type LoggerMgr ¶
type LoggerMgr struct {
// contains filtered or unexported fields
}
func NewLoggerMgr ¶
func NewLoggerMgr() *LoggerMgr
Click to show internal directories.
Click to hide internal directories.