unit

package
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlocksPerMin   = uint64(7)
	BlocksPerHour  = uint64(450)
	BlocksPerDay   = 24 * BlocksPerHour
	BlocksPerWeek  = 7 * BlocksPerDay
	BlocksPerMonth = 30 * BlocksPerDay
	BlocksPerYear  = 365 * BlocksPerDay
)

The block generation rate for DxChain is 8s/block. Therefore, 450 blocks can be generated in an hour

Variables

View Source
var CurrencyIndexMap = map[string]uint64{
	"camel":  1,
	"gcamel": 1e9,
	"dx":     1e18,
}
View Source
var CurrencyUnit = []string{"camel", "gcamel", "dx"}

CurrencyUnit defines available units used for rentPayment fund

View Source
var DataSizeMultiplier = map[string]uint64{
	"kb":  1e3,
	"mb":  1e6,
	"gb":  1e9,
	"tb":  1e12,
	"kib": 1 << 10,
	"mib": 1 << 20,
	"gib": 1 << 30,
	"tib": 1 << 40,
}
View Source
var DataSizeUnit = []string{"kb", "mb", "gb", "tb", "kib", "mib", "gib", "tib"}

DataSizeUnit defines available units used for specifying expected storage size, expected upload size, and expected download size

View Source
var SpeedMultiplier = map[string]int64{
	"bps":  1,
	"kbps": 1e3,
	"mbps": 1e6,
	"gbps": 1e9,
	"tbps": 1e12,
}
View Source
var SpeedUnit = []string{"bps", "kbps", "mbps", "gbps", "tbps"}

SpeedUnit defines available units used for specifying upload and download speed

View Source
var TimeUnit = []string{"h", "b", "d", "w", "m", "y"}

TimeUnit defines available units used for period and renew

Functions

func FormatBool

func FormatBool(value bool) string

FormatBool format a bool value to string

func FormatCurrency

func FormatCurrency(fund common.BigInt, extra ...string) (formatted string)

FormatCurrency is used to format the currency for displaying purpose. The extra string will append to the unit

func FormatSpeed

func FormatSpeed(speed int64) (formatted string)

FormatSpeed is used to format max upload and download field for displaying purpose

func FormatStorage

func FormatStorage(dataSize uint64, storage bool) (formatted string)

FormatStorage is used to format the data for console display purpose

func FormatTime

func FormatTime(time uint64) (formatted string)

FormatTime is used to format the period and renewWindow field for displaying purpose

func ParseBool

func ParseBool(str string) (parsed bool, err error)

ParseBool will parse the string into boolean.

func ParseCurrency

func ParseCurrency(str string) (parsed common.BigInt, err error)

ParseCurrency will parse the user string input, and convert it into common.BigInt type in terms of wei, which is the smallest currency unit

func ParseSpeed

func ParseSpeed(str string) (parsed int64, err error)

ParseSpeed will parse the string into maxUploadSpeed or maxDownloadSpeed which will be used to limit the speed while uploading/downloading data

func ParseStorage

func ParseStorage(str string) (parsed uint64, err error)

ParseStorage will convert the string with the unit into uint64 in the unit of byte

func ParseTime

func ParseTime(str string) (parsed uint64, err error)

ParseTime will parse the string version of period into uint64 type based on the unit provided. The supported units are blocks, hour, day, week, month, year

func ParseUint64

func ParseUint64(data string, factor uint64, unit string) (parsed uint64, err error)

ParseUint64 will convert data to the uint64 format

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL