Documentation
¶
Overview ¶
Provides the data structures and methods to work with the common data structures.
Index ¶
- Constants
- Variables
- func AutoFormatBalance(b Balance) (string, error)
- func AutoFormatStatic(amount int64) (string, error)
- func FormatBalance(b Balance, unit BalanceUnit) (string, error)
- func FormatStatic(amount int64, unit string) (string, error)
- func GetPathFields(p string) ([]string, error)
- func MustAddInt(a, b int) int
- func ParseBalanceStatic(str string) (int64, error)
- func ParseTime(now time.Time, input string) (*time.Time, error)
- func TryAddInt(a, b int) (int, error)
- type Balance
- type BalanceUnit
- type Key
- type Size
- type Timestamp
Constants ¶
View Source
const ( ZCNExponent = 10 // TokenUnit represents the minimum token unit (sas) TokenUnit = 1e10 )
Variables ¶
View Source
var ( // ErrNegativeValue is returned if a float value is a negative number ErrNegativeValue = errors.New("negative coin value") // ErrTooManyDecimals is returned if a value has more than 10 decimal places ErrTooManyDecimals = errors.New("too many decimal places") // ErrTooLarge is returned if a value is greater than math.MaxInt64 ErrTooLarge = errors.New("value is too large") // ErrUint64OverflowsFloat64 is returned if when converting a uint64 to a float64 overflow float64 ErrUint64OverflowsFloat64 = errors.New("uint64 overflows float64") // ErrUint64AddOverflow is returned if when adding uint64 values overflow uint64 ErrUint64AddOverflow = errors.New("uint64 addition overflow") )
View Source
var ErrInvalidTime = errors.New("invalid time")
View Source
var MemPool bytebufferpool.Pool
Functions ¶
func AutoFormatBalance ¶
AutoFormatBalance returns a string representation of the balance with the most
func AutoFormatStatic ¶
func FormatBalance ¶
func FormatBalance(b Balance, unit BalanceUnit) (string, error)
FormatBalance returns a string representation of the balance with the given unit.
func GetPathFields ¶
func MustAddInt ¶
func ParseBalanceStatic ¶
Types ¶
type Balance ¶
type Balance uint64
Balance represents client's balance in Züs native token fractions (SAS = 10^-10 ZCN).
func AddBalance ¶
AddBalance adds c and b, returning an error if the values overflow
func ParseBalance ¶
func (Balance) AutoFormat ¶
AutoFormat returns a string representation of the balance with the most
type BalanceUnit ¶
type BalanceUnit byte
const ( SAS BalanceUnit = iota UZCN MZCN ZCN )
func (*BalanceUnit) Parse ¶
func (unit *BalanceUnit) Parse(s string) error
func (BalanceUnit) String ¶
func (unit BalanceUnit) String() string
type Key ¶
type Key string
A Key represents an identifier. It can be a pool ID, client ID, smart contract address, etc.
Click to show internal directories.
Click to hide internal directories.