common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashLength    = 32
	AddressLength = 20
)

Lengths of hashes and addresses in bytes.

Variables

This section is empty.

Functions

func BytesToAddress

func BytesToAddress(b []byte) types.Address

BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.

func BytesToHash

func BytesToHash(b []byte) types.Hash

BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.

func FromHex

func FromHex(s string) []byte

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

func HashAlg added in v1.0.0

func HashAlg() hash.Hash

get hash algorithm by global config

func HeaderHash

func HeaderHash(block *types.Block) (hash types.Hash)

HeaderHash calculate block's hash

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func HexToAddress

func HexToAddress(s string) types.Address

HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.

func HexToHash

func HexToHash(s string) types.Hash

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

func TxHash

func TxHash(tx *types.Transaction) (hash types.Hash)

TxHash calculate tx's hash

Types

This section is empty.

Jump to

Keyboard shortcuts

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