common

package
v0.0.0-...-037434f Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package common contains various helper functions.

Index

Constants

View Source
const (
	HashLength    = 32
	AddressLength = 20
)

Variables

This section is empty.

Functions

func Bytes2Hex

func Bytes2Hex(d []byte) string

Bytes2Hex returns the hexadecimal encoding of d.

func Bytes2Uint

func Bytes2Uint(d []byte) uint64

func CopyBytes

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

CopyBytes returns an exact copy of the provided bytes.

func FromHex

func FromHex(s string) []byte

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

func GetLogger

func GetLogger(namespace string) *logging.Logger

func Hex

func Hex(b []byte) []byte

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 LeftPadBytes

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

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

func RightPadBytes

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

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

func Uint2Bytes

func Uint2Bytes(v uint64) []byte

Types

type Address

type Address [AddressLength]byte

func BigToAddress

func BigToAddress(b *big.Int) Address

func BytesToAddress

func BytesToAddress(b []byte) Address

func CreateAddress

func CreateAddress(addr Address, nonce uint64) Address

func HashToAddr

func HashToAddr(hash Hash) Address

func HexToAddress

func HexToAddress(d string) Address

Decode address in hex format to common.Address

func (Address) Big

func (addr Address) Big() *big.Int

func (Address) Bytes

func (addr Address) Bytes() []byte

func (Address) Hex

func (addr Address) Hex() string

func (Address) Nil

func (addr Address) Nil() bool

func (Address) String

func (addr Address) String() string

type Config

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

func NewConfig

func NewConfig(path string) *Config

func (*Config) Get

func (c *Config) Get(key string) interface{}

func (*Config) GetBool

func (c *Config) GetBool(key string) bool

func (*Config) GetDuration

func (c *Config) GetDuration(key string) time.Duration

func (*Config) GetInt

func (c *Config) GetInt(key string) int

func (*Config) GetInt64

func (c *Config) GetInt64(key string) int64

func (*Config) GetSlice

func (c *Config) GetSlice(key string) []string

func (*Config) GetString

func (c *Config) GetString(key string) string

type Hash

type Hash [HashLength]byte

func BigToHash

func BigToHash(b *big.Int) Hash

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 BytesToHash(d []byte) Hash

func DecodeHash

func DecodeHash(data []byte) Hash

Decode hash string with "0x...." format to Hash type

func HexToHash

func HexToHash(s string) Hash

HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.

func Sha256

func Sha256(d []byte) Hash

func (Hash) Big

func (h Hash) Big() *big.Int

func (Hash) Bytes

func (h Hash) Bytes() []byte

func (Hash) Hex

func (h Hash) Hex() string

func (Hash) Nil

func (h Hash) Nil() bool

func (Hash) String

func (h Hash) String() string

type Logger

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

type LoggerMgr

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

func NewLoggerMgr

func NewLoggerMgr() *LoggerMgr

func (*LoggerMgr) AddLogger

func (mgr *LoggerMgr) AddLogger(log *Logger)

func (*LoggerMgr) GetLogger

func (mgr *LoggerMgr) GetLogger(namespace string) *logging.Logger

Jump to

Keyboard shortcuts

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