util

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayReverse

func ArrayReverse(b []byte) []byte

ArrayReverse return a reversed version of the given byte slice.

Types

type Fixed8

type Fixed8 int64

Fixed8 represents a fixed-point number with precision 10^-8.

func Fixed8FromFloat

func Fixed8FromFloat(val float64) Fixed8

Fixed8FromFloat returns a new Fixed8 type multiplied by decimals.

func Fixed8FromInt64

func Fixed8FromInt64(val int64) Fixed8

Fixed8FromInt64 returns a new Fixed8 type multiplied by decimals.

func Fixed8FromString

func Fixed8FromString(s string) (Fixed8, error)

Fixed8FromString parses s which must be a fixed point number with precision up to 10^-8

func Satoshi

func Satoshi() Fixed8

Satoshi defines the value of a 'Satoshi'.

func (Fixed8) Add

func (f Fixed8) Add(g Fixed8) Fixed8

Add implements Fixd8 addition operator.

func (Fixed8) CompareTo

func (f Fixed8) CompareTo(g Fixed8) int

CompareTo returns the difference between the f and g. difference < 0 implies f < g. difference = 0 implies f = g. difference > 0 implies f > g.

func (Fixed8) Div

func (f Fixed8) Div(i int64) Fixed8

Div implements Fixd8 division operator.

func (Fixed8) Equal

func (f Fixed8) Equal(g Fixed8) bool

Equal implements Fixd8 == operator.

func (Fixed8) FloatValue

func (f Fixed8) FloatValue() float64

FloatValue returns the original value representing Fixed8 as float64.

func (Fixed8) GreaterThan

func (f Fixed8) GreaterThan(g Fixed8) bool

GreaterThan implements Fixd8 < operator.

func (Fixed8) Int64Value

func (f Fixed8) Int64Value() int64

Int64Value returns the original value representing Fixed8 as int64.

func (Fixed8) LessThan

func (f Fixed8) LessThan(g Fixed8) bool

LessThan implements Fixd8 < operator.

func (Fixed8) MarshalJSON

func (f Fixed8) MarshalJSON() ([]byte, error)

MarshalJSON implements the json marshaller interface.

func (Fixed8) String

func (f Fixed8) String() string

String implements the Stringer interface.

func (Fixed8) Sub

func (f Fixed8) Sub(g Fixed8) Fixed8

Sub implements Fixd8 subtraction operator.

func (*Fixed8) UnmarshalJSON

func (f *Fixed8) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json unmarshaller interface.

type Uint160

type Uint160 [uint160Size]uint8

Uint160 is a 20 byte long unsigned integer.

func Uint160DecodeBytes

func Uint160DecodeBytes(b []byte) (u Uint160, err error)

Uint160DecodeBytes attempts to decode the given bytes into an Uint160.

func Uint160DecodeString

func Uint160DecodeString(s string) (Uint160, error)

Uint160DecodeString attempts to decode the given string into an Uint160.

func (Uint160) Bytes

func (u Uint160) Bytes() []byte

Bytes returns the byte slice representation of u.

func (Uint160) BytesReverse

func (u Uint160) BytesReverse() []byte

BytesReverse return a reversed byte representation of u.

func (Uint160) Equals

func (u Uint160) Equals(other Uint160) bool

Equals returns true if both Uint256 values are the same.

func (Uint160) Less added in v0.51.0

func (u Uint160) Less(other Uint160) bool

Less returns true if this value is less than given Uint160 value. It's primarily intended to be used for sorting purposes.

func (Uint160) MarshalJSON

func (u Uint160) MarshalJSON() ([]byte, error)

MarshalJSON implements the json marshaller interface.

func (Uint160) ReverseString

func (u Uint160) ReverseString() string

ReverseString is the same as String, but returnes an inversed representation.

func (Uint160) String

func (u Uint160) String() string

String implements the stringer interface.

func (*Uint160) UnmarshalJSON

func (u *Uint160) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json unmarshaller interface.

type Uint256

type Uint256 [uint256Size]uint8

Uint256 is a 32 byte long unsigned integer.

func Uint256DecodeBytes

func Uint256DecodeBytes(b []byte) (u Uint256, err error)

Uint256DecodeBytes attempts to decode the given string (in BE representation) into an Uint256.

func Uint256DecodeReverseBytes

func Uint256DecodeReverseBytes(b []byte) (u Uint256, err error)

Uint256DecodeReverseBytes attempts to decode the given string (in LE representation) into an Uint256.

func Uint256DecodeReverseString

func Uint256DecodeReverseString(s string) (u Uint256, err error)

Uint256DecodeReverseString attempts to decode the given string (in LE representation) into an Uint256.

func (Uint256) Bytes

func (u Uint256) Bytes() []byte

Bytes returns a byte slice representation of u.

func (Uint256) BytesReverse

func (u Uint256) BytesReverse() []byte

BytesReverse return a reversed byte representation of u.

func (Uint256) CompareTo

func (u Uint256) CompareTo(other Uint256) int

CompareTo compares two Uint256 with each other. Possible output: 1, -1, 0

1 implies u > other.

-1 implies u < other.

0 implies  u = other.

func (Uint256) Equals

func (u Uint256) Equals(other Uint256) bool

Equals returns true if both Uint256 values are the same.

func (Uint256) MarshalJSON

func (u Uint256) MarshalJSON() ([]byte, error)

MarshalJSON implements the json marshaller interface.

func (Uint256) Reverse

func (u Uint256) Reverse() Uint256

Reverse reverses the Uint256 object

func (Uint256) ReverseString

func (u Uint256) ReverseString() string

ReverseString produces string representation of Uint256 with LE byte order.

func (Uint256) String

func (u Uint256) String() string

String implements the stringer interface.

func (*Uint256) UnmarshalJSON

func (u *Uint256) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json unmarshaller interface.

Jump to

Keyboard shortcuts

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