common

package
v0.0.0-...-ee99c87 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

* * @file * @copyright defined in go-seele/LICENSE

Index

Constants

View Source
const (
	// HashLength the leghth of hash
	HashLength = 32
)

Variables

This section is empty.

Functions

func ConvertInt64ToBytes

func ConvertInt64ToBytes(num int64) []byte

ConvertInt64ToBytes Converts a int64 value into a byte array

func Deserialize

func Deserialize(data []byte, value interface{}) error

Deserialize wrapper decode

func Serialize

func Serialize(in interface{}) ([]byte, error)

Serialize wrapper encode

func SerializePanic

func SerializePanic(in interface{}) []byte

SerializePanic serialize the input data to byte array. Panics on error, e.g. unsupported data type for RLP encoding.

Types

type Address

type Address [addressIDBits / 8]byte

Address we use public key as node id

func GenerateRandomAddress

func GenerateRandomAddress() (*Address, error)

func HexToAddress

func HexToAddress(id string) Address

func NewAddress

func NewAddress(b []byte) (Address, error)

NewAddress converts a byte slice to a Address

func (*Address) Bytes

func (id *Address) Bytes() []byte

Bytes get the actual bytes

func (*Address) ToSha

func (id *Address) ToSha() Hash

ToSha get the node hash

type Hash

type Hash [HashLength]byte

Hash the hash value generated by sha-3

var EmptyHash Hash = Hash{}

func BytesToHash

func BytesToHash(b []byte) Hash

BytesToHash convert bytes to hash value

func HashBytes

func HashBytes(value []byte) Hash

func StringToHash

func StringToHash(s string) Hash

StringToHash string to hash

func (Hash) Bytes

func (a Hash) Bytes() []byte

Bytes return its actual bits

func (*Hash) SetBytes

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

SetBytes sets the hash to the value of b. If b is larger than len(a) it will panic

func (Hash) String

func (a Hash) String() string

String to string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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