common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DATA
	DATA_BLOCK       DataEntryPrefix = 0x00 //Block height => block hash key prefix
	DATA_HEADER                      = 0x01 //Block hash => block hash key prefix
	DATA_TRANSACTION                 = 0x02 //Transction hash = > transaction key prefix
	HashLength                       = 32
	AddressLength                    = 20
)

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 Encode

func Encode(b []byte) string

Encode encodes b as a hex string with 0x prefix.

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 HashToBytes

func HashToBytes(hash types.Hash) []byte

HashToBytes convert hash to []byte

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 Serialize

func Serialize(w io.Writer, f *int64) error

func TxHash

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

TxHash calculate tx's hash

func WriteUint32

func WriteUint32(writer io.Writer, val uint32) error

func WriteUint64

func WriteUint64(writer io.Writer, val uint64) error

func WriteVarBytes

func WriteVarBytes(writer io.Writer, value []byte) error

func WriteVarUint

func WriteVarUint(writer io.Writer, value uint64) error

Types

type DataEntryPrefix

type DataEntryPrefix byte

Jump to

Keyboard shortcuts

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