utils

package
v2.0.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: MIT Imports: 16 Imported by: 1

Documentation

Overview

Package utils provides miscellanious helpers and utilities

Index

Constants

View Source
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

func CalculateGarbageCollectDate(holdTimeInMonths int) time.Time

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

func FloatToBigInt(val float64) *big.Int

FloatToBigInt used to convert a float to big int

func GenerateMultiAddrFromString

func GenerateMultiAddrFromString(addr string) (ma.Multiaddr, error)

GenerateMultiAddrFromString is used to take a string, and convert it to a multiformat based address

func ParseMultiAddrForIPFSPeer

func ParseMultiAddrForIPFSPeer(address ma.Multiaddr) (bool, error)

ParseMultiAddrForIPFSPeer is used to parse a multiaddress to determine whether its a valid ipfs address

func ParsePeerIDFromIPFSMultiAddr

func ParsePeerIDFromIPFSMultiAddr(address ma.Multiaddr) (string, error)

ParsePeerIDFromIPFSMultiAddr is used to parse a multiaddress and extract the IPFS peer id

func RetrieveUsdPrice

func RetrieveUsdPrice(coin string) (float64, error)

RetrieveUsdPrice is used to retrieve the USD price for a coin from CMC

Types

type RandomUtils

type RandomUtils struct {
	Seed *rand.Rand
}

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

func (*RandomUtils) ReSeed

func (u *RandomUtils) ReSeed()

ReSeed is used to reseed our RNG

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

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Shell is used to interact with clamav

func NewShell

func NewShell(address string) (*Shell, error)

NewShell is used to instantiate our connection to a clamav daemon

func (*Shell) Scan

func (s *Shell) Scan(reader io.Reader) error

Scan is used to scan a file reader

Jump to

Keyboard shortcuts

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