utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2016 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializePriceConverter

func InitializePriceConverter(typ string) error

InitializePriceConverter initialize price converter only once

Example
for _, typ := range []string{"usd", "btc", "unknown"} {
	fmt.Println(InitializePriceConverter(typ))
}
Output:

<nil>
<nil>
converter unknown not exist

func RandomReward

func RandomReward(rates []models.RewardRate) int64

RandomReward generates a random reward with rates given

func ToHuman

func ToHuman(i int64) float64

ToHuman converts to human readable price

Example
InitializePriceConverter("usd")
fmt.Println(humanReadableUSD(10))

InitializePriceConverter("btc")
fmt.Println(ToHuman(100000))
Output:

0.001
0.001

func ToMachine

func ToMachine(f float64) int64

ToMachine converts to what machine want to save in db

Example
InitializePriceConverter("usd")
fmt.Println(ToMachine(0.01))

InitializePriceConverter("btc")
fmt.Println(machineReadableBTC(0.01))
Output:

100
1000000

Types

This section is empty.

Jump to

Keyboard shortcuts

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