Documentation
¶
Overview ¶
Package utils provides miscellanious helpers and utilities
Index ¶
- Constants
- func CalculateFileCost(username string, holdTimeInMonths, size int64, um *models.UsageManager) (float64, error)
- func CalculateGarbageCollectDate(holdTimeInMonths int) time.Time
- func CalculatePinCost(username, contentHash string, holdTimeInMonths int64, im rtfs.Manager, ...) (float64, error)
- func FloatToBigInt(val float64) *big.Int
- func GenerateMultiAddrFromString(addr string) (ma.Multiaddr, error)
- func ParseMultiAddrForIPFSPeer(address ma.Multiaddr) (bool, error)
- func ParsePeerIDFromIPFSMultiAddr(address ma.Multiaddr) (string, error)
- func RetrieveUsdPrice(coin string) (float64, error)
- type RandomUtils
- type Response
- type Shell
Constants ¶
const (
// LetterBytes are the letters of an alphabet used to generate a random number
LetterBytes = "abcdefghijklmnopqrstuvwxyz"
)
Variables ¶
This section is empty.
Functions ¶
func CalculateFileCost ¶
func CalculateFileCost(username string, holdTimeInMonths, size int64, um *models.UsageManager) (float64, error)
CalculateFileCost is used to calculate the cost of storing a file
func CalculateGarbageCollectDate ¶
CalculateGarbageCollectDate is used to calculate the date at which data is removed from our system
func CalculatePinCost ¶
func CalculatePinCost(username, contentHash string, holdTimeInMonths int64, im rtfs.Manager, um *models.UsageManager) (float64, error)
CalculatePinCost is used to calculate the cost of pining a particular content hash
func FloatToBigInt ¶
FloatToBigInt used to convert a float to big int
func GenerateMultiAddrFromString ¶
GenerateMultiAddrFromString is used to take a string, and convert it to a multiformat based address
func ParseMultiAddrForIPFSPeer ¶
ParseMultiAddrForIPFSPeer is used to parse a multiaddress to determine whether its a valid ipfs address
func ParsePeerIDFromIPFSMultiAddr ¶
ParsePeerIDFromIPFSMultiAddr is used to parse a multiaddress and extract the IPFS peer id
func RetrieveUsdPrice ¶
RetrieveUsdPrice is used to retrieve the USD price for a coin from CMC
Types ¶
type RandomUtils ¶
RandomUtils is our helper struct for random related utilities
func GenerateRandomUtils ¶
func GenerateRandomUtils() *RandomUtils
GenerateRandomUtils is used to generate our random utils struct
func (*RandomUtils) GenerateString ¶
func (u *RandomUtils) GenerateString(length int, charset string) string
GenerateString is used to generate a fixed length random string from the specified charset, using a fresh seed each time
type Response ¶
type Response struct {
ID string `json:"id"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Rank string `json:"rank"`
PriceUsd string `json:"price_usd"`
PriceBtc string `json:"price_btc"`
TwentyFourHrVolume string `json:"24h_volume_usd"`
MarketCapUsd string `json:"market_cap_usd"`
AvailableSupply string `json:"available_supply"`
TotalSupply string `json:"total_supply"`
MaxSupply string `json:"null"`
PercentChange1h string `json:"percent_change_1h"`
PercentChange24h string `json:"percent_change_24h"`
PercentChange7d string `json:"percent_change_7d"`
LastUpdate string `json:"last_updated"`
}
Response used to hold response data from cmc