types

package
v0.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package types defines common types.

Index

Constants

View Source
const Bytes20Size = 20

Bytes20Size is the size of a 20-byte long byte array.

View Source
const Bytes32Size = 32

Bytes32Size is the size of a 32-byte long byte array.

Variables

View Source
var Bytes32Zero = &Bytes32{}

Bytes32Zero is the default value for a 32-byte long byte array.

Functions

This section is empty.

Types

type Bytes20

type Bytes20 [Bytes20Size]byte

Bytes20 is a 20-byte long byte array.

func NewBytes20FromString

func NewBytes20FromString(src string) (*Bytes20, error)

NewBytes20FromString creates a Bytes20 from a hex encoded string.

func (*Bytes20) MarshalJSON

func (b *Bytes20) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (*Bytes20) Reverse

func (b *Bytes20) Reverse(rb *ReversedBytes20)

Reverse reverses the bytes order.

func (*Bytes20) String

func (b *Bytes20) String() string

String returns a hex encoded string.

func (*Bytes20) UnmarshalJSON

func (b *Bytes20) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

func (*Bytes20) Unstring

func (b *Bytes20) Unstring(src string) error

Unstring sets the value from a hex encoded string.

type Bytes32

type Bytes32 [Bytes32Size]byte

Bytes32 is a 32-byte long byte array.

func NewBytes32FromBytes added in v0.2.0

func NewBytes32FromBytes(src []byte) *Bytes32

NewBytes32FromBytes creates a Bytes32 from a byte slice.

func NewBytes32FromString

func NewBytes32FromString(src string) (*Bytes32, error)

NewBytes32FromString creates a Bytes32 from a hex encoded string.

func (*Bytes32) Compare

func (b *Bytes32) Compare(b2 *Bytes32) int

Compare compares two Bytes32

func (*Bytes32) Equals added in v0.2.0

func (b *Bytes32) Equals(b2 *Bytes32) bool

Equals checks if two Bytes32 are equal

func (*Bytes32) EqualsBytes added in v0.2.0

func (b *Bytes32) EqualsBytes(b2 []byte) bool

EqualsBytes checks if a byte slice equals a Bytes32

func (*Bytes32) MarshalJSON

func (b *Bytes32) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (*Bytes32) Reverse

func (b *Bytes32) Reverse(rb *ReversedBytes32)

Reverse reverses the bytes order.

func (*Bytes32) String

func (b *Bytes32) String() string

String returns a hex encoded string.

func (*Bytes32) UnmarshalJSON

func (b *Bytes32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

func (*Bytes32) Unstring

func (b *Bytes32) Unstring(src string) error

Unstring sets the value from a hex encoded string.

func (*Bytes32) Value added in v0.2.0

func (b *Bytes32) Value() (driver.Value, error)

Value implements the database.sql.driver.Valuer interface.

func (*Bytes32) Zero added in v0.2.0

func (b *Bytes32) Zero() bool

Zero checks if a Bytes32 is the default value or nil

type MerkleNodeHashes added in v0.2.0

type MerkleNodeHashes struct {
	Left   Bytes32 `json:"left"`
	Right  Bytes32 `json:"right"`
	Parent Bytes32 `json:"parent"`
}

MerkleNodeHashes contains a left, right, and parent hash.

func (MerkleNodeHashes) Validate added in v0.2.0

func (h MerkleNodeHashes) Validate() error

Validate validates the integrity of a hash triplet.

type Path added in v0.2.0

type Path []MerkleNodeHashes

Path contains the necessary hashes to go from a leaf to a Merkle root.

func (Path) Validate added in v0.2.0

func (p Path) Validate() error

Validate validates the integrity of a Merkle path.

type ReversedBytes20

type ReversedBytes20 [Bytes20Size]byte

ReversedBytes20 is a 20-byte long byte reversed array. While the bytes are reversed, the hex encoded strings are not.

func NewReversedBytes20FromString

func NewReversedBytes20FromString(src string) (*ReversedBytes20, error)

NewReversedBytes20FromString creates a ReversedBytes20 from a hex encoded string.

func (*ReversedBytes20) MarshalJSON

func (rb *ReversedBytes20) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (*ReversedBytes20) Reverse

func (rb *ReversedBytes20) Reverse(b *Bytes20)

Reverse reverses the bytes order.

func (*ReversedBytes20) String

func (rb *ReversedBytes20) String() string

String returns a hex encoded string.

func (*ReversedBytes20) UnmarshalJSON

func (rb *ReversedBytes20) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

func (*ReversedBytes20) Unstring

func (rb *ReversedBytes20) Unstring(src string) error

Unstring sets the value from a hex encoded string.

type ReversedBytes32

type ReversedBytes32 [Bytes32Size]byte

ReversedBytes32 is a 32-byte long byte reversed array. While the bytes are reversed, the hex encoded strings are not.

func NewReversedBytes32FromString

func NewReversedBytes32FromString(src string) (*ReversedBytes32, error)

NewReversedBytes32FromString creates a ReversedBytes32 from a hex encoded string.

func (*ReversedBytes32) MarshalJSON

func (rb *ReversedBytes32) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (*ReversedBytes32) Reverse

func (rb *ReversedBytes32) Reverse(b *Bytes32)

Reverse reverses the bytes order.

func (*ReversedBytes32) String

func (rb *ReversedBytes32) String() string

String returns a hex encoded string.

func (*ReversedBytes32) UnmarshalJSON

func (rb *ReversedBytes32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

func (*ReversedBytes32) Unstring

func (rb *ReversedBytes32) Unstring(src string) error

Unstring sets the value from a hex encoded string.

type TransactionID added in v0.2.0

type TransactionID []byte

TransactionID is a blockchain transaction ID.

func (TransactionID) MarshalJSON added in v0.2.0

func (txid TransactionID) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON.

func (TransactionID) String added in v0.2.0

func (txid TransactionID) String() string

String returns a hex encoded string.

func (*TransactionID) UnmarshalJSON added in v0.2.0

func (txid *TransactionID) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON.

Jump to

Keyboard shortcuts

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