utils

package
v2.0.0-rc1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2018 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// UsdPerGigaBytePerMonthPublic is the usd cost of storing a gigabyte of data in public networks for a month
	UsdPerGigaBytePerMonthPublic = 0.134
	// UsdPerGigaBytePerMonthPrivate is the usd cost of storing a gigabyte of data in private networks for a month
	UsdPerGigaBytePerMonthPrivate = 0.154
	// PubSubPublishPublic is the of cost of sending a pubsub message to the public ipfs network
	PubSubPublishPublic = 0.01
	// PubSubPublishPrivate is the cost of sending a pubsub message to a private ipfs network
	PubSubPublishPrivate = 0.02
	// IPNSPublishPublic is the cost of publishing an IPNS record to the public ipfs network
	IPNSPublishPublic = 5.00
	// IPNSPublishPrivate is the cost of publishing an IPNS record to the a private ipfs network
	IPNSPublishPrivate = 10.00
	// RSAKeyCreationPublic is the cost of creating an rsa key on the public ipfs network
	RSAKeyCreationPublic = 2.00
	// RSAKeyCreationPrivate is the cost of creating an rsa key on a private ifps network
	RSAKeyCreationPrivate = 2.50
	// EDKeyCreationPublic is the cost of creating an ed25519 key on the public ipfs network
	EDKeyCreationPublic = 1.00
	// EDKeyCreationPrivate is the cost of creating an ed25519 key on a private ipfs network
	EDKeyCreationPrivate = 1.50
)

prices listed here are temporary and will be changed

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 CalculateAPICallCost

func CalculateAPICallCost(callType string, privateNetwork bool) (float64, error)

CalculateAPICallCost is used to calculate the cost associated with an API call, that isn't related to uploads/pinning

func CalculateFileCost

func CalculateFileCost(holdTimeInMonths, size int64, privateNetwork bool) float64

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(contentHash string, holdTimeInMonths int64, im rtfs.Manager, privateNetwork bool) (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

Jump to

Keyboard shortcuts

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