types

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 7 Imported by: 52

Documentation

Index

Constants

View Source
const (
	HashLength    = 32
	AddressLength = 20
)

Lengths of hashes and addresses in bytes.

Variables

This section is empty.

Functions

func HexDecodeString added in v1.0.1

func HexDecodeString(s string) ([]byte, error)

HexDecodeString return rawBytes of a hex hash represent

func IsValidAddressByte added in v1.0.1

func IsValidAddressByte(data []byte) bool

Types

type Address

type Address struct {
	RawAddress [AddressLength]byte
	Address    string
}

func NewAddress added in v1.0.1

func NewAddress(b []byte) *Address

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

func NewAddressByStr added in v1.0.1

func NewAddressByStr(s string) *Address

func (*Address) Bytes

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

func (*Address) MarshalJSON

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

Serialize given address to JSON

func (*Address) MarshalTo

func (a *Address) MarshalTo(data []byte) (int, error)

func (*Address) ProtoMessage added in v1.0.1

func (a *Address) ProtoMessage()

func (*Address) Reset added in v1.0.1

func (a *Address) Reset()

func (*Address) Set

func (a *Address) Set(other *Address)

Sets a to other

func (*Address) SetBytes

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

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

func (*Address) SetString added in v1.0.1

func (a *Address) SetString(s string)

func (*Address) Size

func (a *Address) Size() int

func (*Address) String

func (a *Address) String() string

String returns an EIP55-compliant hex string representation of the address.

func (*Address) Unmarshal

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

func (*Address) UnmarshalJSON

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

UnmarshalJSON parses a hash in hex syntax.

type Hash

type Hash struct {
	RawHash [HashLength]byte
	Hash    string
}

func NewHash added in v1.0.1

func NewHash(b []byte) *Hash

func NewHashByStr added in v1.0.1

func NewHashByStr(s string) *Hash

func (*Hash) Bytes

func (h *Hash) Bytes() []byte

func (*Hash) CalculateHash added in v1.0.1

func (h *Hash) CalculateHash() ([]byte, error)

CalculateHash hashes the values of a TestContent

func (*Hash) Equals added in v1.0.1

func (h *Hash) Equals(other mt.Content) (bool, error)

Equals tests for equality of two Contents

func (*Hash) MarshalJSON

func (h *Hash) MarshalJSON() ([]byte, error)

Serialize given address to JSON

func (*Hash) MarshalTo

func (h *Hash) MarshalTo(data []byte) (int, error)

func (*Hash) ProtoMessage added in v1.0.1

func (h *Hash) ProtoMessage()

func (*Hash) Reset added in v1.0.1

func (h *Hash) Reset()

func (*Hash) SetBytes

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

func (*Hash) SetString added in v1.0.1

func (h *Hash) SetString(s string)

func (Hash) Size

func (h Hash) Size() int

func (*Hash) String

func (h *Hash) String() string

func (*Hash) Unmarshal

func (h *Hash) Unmarshal(data []byte) error

func (*Hash) UnmarshalJSON

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

Jump to

Keyboard shortcuts

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