common

package
v1.3.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoFormatBalance added in v1.2.86

func AutoFormatBalance(b Balance) string

func AutoFormatStatic added in v1.2.88

func AutoFormatStatic(amount int64) string

func FormatBalance added in v1.2.86

func FormatBalance(b Balance, unit BalanceUnit) string

func FormatStatic added in v1.2.88

func FormatStatic(amount int64, unit string) string

func ParseBalanceStatic added in v1.2.88

func ParseBalanceStatic(str string) (int64, error)

Types

type Balance

type Balance int64

Balance represents 0chain native token

func ParseBalance added in v1.2.86

func ParseBalance(str string) (Balance, error)

func ToBalance

func ToBalance(token float64) Balance

ToBalance converts ZCN tokens to Balance.

func (Balance) AutoFormat added in v1.2.86

func (b Balance) AutoFormat() string

func (Balance) Format added in v1.2.86

func (b Balance) Format(unit BalanceUnit) string

func (Balance) String

func (b Balance) String() string

String implements fmt.Stringer interface.

func (Balance) ToToken

func (b Balance) ToToken() float64

type BalanceUnit added in v1.2.86

type BalanceUnit byte
const (
	SAS BalanceUnit = iota
	UZCN
	MZCN
	ZCN
)

func (*BalanceUnit) Parse added in v1.2.86

func (unit *BalanceUnit) Parse(s string) error

func (BalanceUnit) String added in v1.2.86

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.

type Size

type Size int64

A Size represents a size in bytes.

func (Size) String

func (s Size) String() string

String implements fmt.Stringer interface

type Timestamp

type Timestamp int64

Timestamp represents Unix time (e.g. in seconds)

func Now

func Now() Timestamp

Now - current datetime

func (Timestamp) ToTime

func (t Timestamp) ToTime() time.Time

ToTime converts the Timestamp to standard time.Time

func (Timestamp) Within

func (t Timestamp) Within(seconds Timestamp) bool

Within ensures a given timestamp is within certain number of seconds

type WhoPays

type WhoPays int

WhoPays for file downloading.

const (
	WhoPaysOwner    WhoPays = iota // 0, file owner pays
	WhoPays3rdParty                // 1, 3rd party user pays
)

possible variants

func (*WhoPays) Parse

func (wp *WhoPays) Parse(val string) (err error)

Parse given string and set the WhoPays by it. Or return parsing error. The given string should be as result of the String method (case insensitive).

func (WhoPays) String

func (wp WhoPays) String() string

String implements fmt.Stringer interface.

func (WhoPays) Validate

func (wp WhoPays) Validate() (err error)

Validate the WhoPays value.

Directories

Path Synopsis
errors module

Jump to

Keyboard shortcuts

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