common

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UINT168SIZE = 21
	// Address types
	STANDARD   = 0xAC
	MULTISIG   = 0xAE
	CROSSCHAIN = 0xAF
)
View Source
const (
	// MaxVarStringLength is the maximum bytes a var string.
	MaxVarStringLength = 1024 * 1024 * 16 // 16MB

)
View Source
const UINT160SIZE int = 20
View Source
const UINT256SIZE = 32

Variables

View Source
var EmptyHash = Uint256{}

Functions

func BytesReverse

func BytesReverse(u []byte) []byte

func BytesToHexString

func BytesToHexString(data []byte) string

func BytesToInt16 added in v0.2.2

func BytesToInt16(b []byte) int16

func ClearBytes added in v0.2.2

func ClearBytes(arr []byte)

func FuncError added in v0.2.2

func FuncError(f string, desc string) error

FuncError creates an error for the given function and description.

func Goid added in v0.3.0

func Goid() string

Goid returns the current goroutine id.

func HexStringToBytes

func HexStringToBytes(value string) ([]byte, error)

func IntToBytes added in v0.2.2

func IntToBytes(n int) []byte

func ReadBytes added in v0.2.2

func ReadBytes(r io.Reader, length uint64) ([]byte, error)

func ReadElement added in v0.2.2

func ReadElement(r io.Reader, element interface{}) (err error)

readElement reads the next sequence of bytes from r using little endian depending on the concrete type of element pointed to.

func ReadElements added in v0.2.2

func ReadElements(r io.Reader, elements ...interface{}) error

ReadElements reads multiple items from r. It is equivalent to multiple calls to ReadElement.

func ReadUint16 added in v0.2.2

func ReadUint16(r io.Reader) (uint16, error)

func ReadUint32 added in v0.2.2

func ReadUint32(r io.Reader) (uint32, error)

func ReadUint64 added in v0.2.2

func ReadUint64(r io.Reader) (uint64, error)

func ReadUint8 added in v0.2.2

func ReadUint8(r io.Reader) (uint8, error)

func ReadVarBytes added in v0.2.2

func ReadVarBytes(r io.Reader, maxAllowed uint32, fieldName string) ([]byte, error)

func ReadVarString added in v0.2.2

func ReadVarString(r io.Reader) (string, error)

func ReadVarUint added in v0.2.2

func ReadVarUint(r io.Reader, pver uint32) (uint64, error)

ReadVarUint reads a variable length integer from r and returns it as a uint64.

func Sha256D added in v0.2.2

func Sha256D(data []byte) [32]byte

func SortProgramHashByCodeHash added in v0.2.2

func SortProgramHashByCodeHash(hashes []Uint168)

func SortUint160 added in v0.2.2

func SortUint160(hashes []Uint160)

func VarUintSerializeSize added in v0.2.2

func VarUintSerializeSize(val uint64) int

VarUintSerializeSize returns the number of bytes it would take to serialize val as a variable length integer.

func WriteElement added in v0.2.2

func WriteElement(w io.Writer, element interface{}) (err error)

WriteElement writes the little endian representation of element to w.

func WriteElements added in v0.2.2

func WriteElements(w io.Writer, elements ...interface{}) error

WriteElements writes multiple items to w. It is equivalent to multiple calls to WriteElement.

func WriteUint16 added in v0.2.2

func WriteUint16(w io.Writer, val uint16) error

func WriteUint32 added in v0.2.2

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

func WriteUint64 added in v0.2.2

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

func WriteUint8 added in v0.2.2

func WriteUint8(w io.Writer, val uint8) error

func WriteVarBytes added in v0.2.2

func WriteVarBytes(w io.Writer, bytes []byte) error

func WriteVarString added in v0.2.2

func WriteVarString(w io.Writer, str string) error

func WriteVarUint added in v0.2.2

func WriteVarUint(w io.Writer, val uint64) error

Types

type Fixed64

type Fixed64 int64

the 64 bit fixed-point number, precise 10^-8

func Fixed64FromBytes added in v0.2.2

func Fixed64FromBytes(value []byte) (*Fixed64, error)

func StringToFixed64 added in v0.2.2

func StringToFixed64(s string) (*Fixed64, error)

func (*Fixed64) Bytes added in v0.2.2

func (f *Fixed64) Bytes() ([]byte, error)

func (*Fixed64) Deserialize

func (f *Fixed64) Deserialize(r io.Reader) error

func (Fixed64) IntValue added in v0.2.2

func (f Fixed64) IntValue() int64

func (*Fixed64) Serialize

func (f *Fixed64) Serialize(w io.Writer) error

func (Fixed64) String

func (f Fixed64) String() string

type Serializable added in v0.2.2

type Serializable interface {
	//Write data to writer
	Serialize(w io.Writer) error

	//read data to reader
	Deserialize(r io.Reader) error
}

Serializable describe the data need be serialized.

type Uint160 added in v0.2.2

type Uint160 [UINT160SIZE]uint8

func ToCodeHash added in v0.2.2

func ToCodeHash(code []byte) *Uint160

func Uint160FromBytes added in v0.2.2

func Uint160FromBytes(bytes []byte) (Uint160, error)

func (Uint160) Bytes added in v0.2.2

func (u Uint160) Bytes() []byte

func (Uint160) Compare added in v0.2.2

func (u Uint160) Compare(o Uint160) int

func (*Uint160) Deserialize added in v0.2.2

func (u *Uint160) Deserialize(r io.Reader) error

func (Uint160) IsEqual added in v0.2.2

func (u Uint160) IsEqual(o Uint160) bool

func (*Uint160) Serialize added in v0.2.2

func (u *Uint160) Serialize(w io.Writer) error

type Uint168

type Uint168 [UINT168SIZE]uint8

func ToProgramHash added in v0.2.2

func ToProgramHash(prefix byte, code []byte) *Uint168

func Uint168FromAddress added in v0.2.2

func Uint168FromAddress(address string) (*Uint168, error)

func Uint168FromBytes

func Uint168FromBytes(bytes []byte) (*Uint168, error)

func Uint168FromCodeHash added in v0.2.2

func Uint168FromCodeHash(prefixType byte, codeHash Uint160) Uint168

func (Uint168) Bytes added in v0.2.2

func (u Uint168) Bytes() []byte

func (Uint168) Compare added in v0.2.2

func (u Uint168) Compare(o Uint168) int

func (*Uint168) Deserialize

func (u *Uint168) Deserialize(r io.Reader) error

func (Uint168) IsEqual added in v0.2.2

func (u Uint168) IsEqual(o Uint168) bool

func (*Uint168) Serialize

func (u *Uint168) Serialize(w io.Writer) error

func (Uint168) String

func (u Uint168) String() string

func (Uint168) ToAddress

func (u Uint168) ToAddress() (string, error)

func (Uint168) ToCodeHash added in v0.2.2

func (u Uint168) ToCodeHash() Uint160

type Uint256

type Uint256 [UINT256SIZE]uint8

func Uint256FromBytes added in v0.2.2

func Uint256FromBytes(f []byte) (*Uint256, error)

func Uint256FromHexString added in v0.0.4

func Uint256FromHexString(hexHash string) (*Uint256, error)

func (Uint256) Bytes added in v0.2.2

func (u Uint256) Bytes() []byte

func (Uint256) Compare added in v0.2.2

func (u Uint256) Compare(o Uint256) int

func (*Uint256) Deserialize

func (u *Uint256) Deserialize(r io.Reader) error

func (Uint256) IsEqual added in v0.2.2

func (u Uint256) IsEqual(o Uint256) bool

func (*Uint256) Serialize

func (u *Uint256) Serialize(w io.Writer) error

func (Uint256) String

func (u Uint256) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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