Documentation ¶
Index ¶
- Constants
- Variables
- func FormatBool(value bool) string
- func FormatCurrency(fund common.BigInt, extra ...string) (formatted string)
- func FormatSpeed(speed int64) (formatted string)
- func FormatStorage(dataSize uint64, storage bool) (formatted string)
- func FormatTime(time uint64) (formatted string)
- func ParseBool(str string) (parsed bool, err error)
- func ParseCurrency(str string) (parsed common.BigInt, err error)
- func ParseSpeed(str string) (parsed int64, err error)
- func ParseStorage(str string) (parsed uint64, err error)
- func ParseTime(str string) (parsed uint64, err error)
- func ParseUint64(data string, factor uint64, unit string) (parsed uint64, err error)
Constants ¶
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 ¶
var CurrencyIndexMap = map[string]uint64{
"camel": 1,
"gcamel": 1e9,
"dx": 1e18,
}
var CurrencyUnit = []string{"camel", "gcamel", "dx"}
CurrencyUnit defines available units used for rentPayment fund
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,
}
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
var SpeedMultiplier = map[string]int64{
"bps": 1,
"kbps": 1e3,
"mbps": 1e6,
"gbps": 1e9,
"tbps": 1e12,
}
var SpeedUnit = []string{"bps", "kbps", "mbps", "gbps", "tbps"}
SpeedUnit defines available units used for specifying upload and download speed
var TimeUnit = []string{"h", "b", "d", "w", "m", "y"}
TimeUnit defines available units used for period and renew
Functions ¶
func FormatCurrency ¶
FormatCurrency is used to format the currency for displaying purpose. The extra string will append to the unit
func FormatSpeed ¶
FormatSpeed is used to format max upload and download field for displaying purpose
func FormatStorage ¶
FormatStorage is used to format the data for console display purpose
func FormatTime ¶
FormatTime is used to format the period and renewWindow field for displaying purpose
func ParseCurrency ¶
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 ¶
ParseSpeed will parse the string into maxUploadSpeed or maxDownloadSpeed which will be used to limit the speed while uploading/downloading data
func ParseStorage ¶
ParseStorage will convert the string with the unit into uint64 in the unit of byte
Types ¶
This section is empty.