common

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressLength = 48
	HashLength    = 32
)

Variables

View Source
var NilHash = [HashLength]byte{0}
View Source
var Sha256Pool = sync.Pool{
	New: func() interface{} {
		return sha3.NewLegacyKeccak256()
	},
}

Functions

func Bytes2Hex added in v1.2.2

func Bytes2Hex(d []byte) string

func CopyBytes added in v1.2.2

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

func FromHex added in v1.2.2

func FromHex(s string) []byte

func Hex2Bytes added in v1.2.2

func Hex2Bytes(str string) []byte

func Hex2BytesFixed added in v1.2.2

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

func LeftPadBytes added in v1.2.2

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

func RightPadBytes added in v1.2.2

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

func TrimLeftZeroes added in v1.2.2

func TrimLeftZeroes(s []byte) []byte

func TrimRightZeroes added in v1.2.2

func TrimRightZeroes(s []byte) []byte

Types

type Address

type Address [AddressLength]byte
var (
	InvalidAddr    Address
	ErrInvalidAddr = fmt.Errorf("invalid ninja address")
)

func HexToAddress

func HexToAddress(s string) (addr Address, err error)

func (*Address) Hex

func (a *Address) Hex() string

func (*Address) MarshalText

func (a *Address) MarshalText() ([]byte, error)

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte) error

func (*Address) String

func (a *Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(data []byte) error

type Hash

type Hash [HashLength]byte

func BigToHash

func BigToHash(b *big.Int) Hash

func BytesToHash

func BytesToHash(b []byte) Hash

func HashOfData added in v1.2.2

func HashOfData(data []byte) (h Hash)

func HexToHash

func HexToHash(s string) 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) MarshalText added in v1.2.2

func (h Hash) MarshalText() ([]byte, error)

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalJSON added in v1.2.2

func (h *Hash) UnmarshalJSON(input []byte) error

func (Hash) Value

func (h Hash) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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