Documentation ¶
Index ¶
- Constants
- Variables
- type APIDetails
- type BillingItem
- type BillingReport
- type DataUsageTier
- type EncryptedUpload
- type EncryptedUploadManager
- type HostedNetwork
- type HostedNetworkManager
- func (im *HostedNetworkManager) CreateHostedPrivateNetwork(name, swarmKey string, peers []string, access NetworkAccessOptions) (*HostedNetwork, error)
- func (im *HostedNetworkManager) Delete(name string) error
- func (im *HostedNetworkManager) GetAPIDetails(network string) (*APIDetails, error)
- func (im *HostedNetworkManager) GetNetworkByName(name string) (*HostedNetwork, error)
- func (im *HostedNetworkManager) GetOfflineNetworks(disabled bool) ([]*HostedNetwork, error)
- func (im *HostedNetworkManager) GetSwarmDetails(network string) (*SwarmDetails, error)
- func (im *HostedNetworkManager) SaveNetwork(n *HostedNetwork) error
- func (im *HostedNetworkManager) UpdateNetworkByName(name string, attrs map[string]interface{}) error
- type IPNS
- type IpnsManager
- func (im *IpnsManager) CreateEntry(ipnsHash, ipfsHash, key, networkName, username string, ...) (*IPNS, error)
- func (im *IpnsManager) FindAll() ([]IPNS, error)
- func (im *IpnsManager) FindByIPNSHash(ipnsHash string) (*IPNS, error)
- func (im *IpnsManager) FindByUserName(username string) (*[]IPNS, error)
- func (im *IpnsManager) UpdateIPNSEntry(ipnsHash, ipfsHash, networkName, username string, lifetime, ttl time.Duration) (*IPNS, error)
- type NetworkAccessOptions
- type OrgManager
- func (om *OrgManager) DecreaseAmountOwed(name string, amount float64) error
- func (om *OrgManager) FindByName(name string) (*Organization, error)
- func (om *OrgManager) GenerateBillingReport(name string, minTime, maxTime time.Time) (*BillingReport, error)
- func (om *OrgManager) GetOrgUsers(name string) ([]string, error)
- func (om *OrgManager) GetTotalStorageUsed(name string) (uint64, error)
- func (om *OrgManager) GetUserUploads(orgName, username string) ([]Upload, error)
- func (om *OrgManager) IncreaseAmountOwed(name string, amount float64) error
- func (om *OrgManager) NewOrganization(name, owner string) (*Organization, error)
- func (om *OrgManager) RegisterOrgUser(orgName, username, password, email string) (*User, error)
- type Organization
- type PaymentManager
- func (pm *PaymentManager) ConfirmPayment(txHash string) (*Payments, error)
- func (pm *PaymentManager) FindPaymentByNumber(username string, number int64) (*Payments, error)
- func (pm *PaymentManager) FindPaymentByTxHash(txHash string) (*Payments, error)
- func (pm *PaymentManager) GetLatestPaymentNumber(username string) (int64, error)
- func (pm *PaymentManager) NewPayment(number int64, depositAddress string, txHash string, ...) (*Payments, error)
- func (pm *PaymentManager) UpdatePaymentTxHash(username, txHash string, number int64) (*Payments, error)
- type Payments
- type Record
- type RecordManager
- func (rm *RecordManager) AddRecord(username, recordName, recordKeyName, zoneName string, ...) (*Record, error)
- func (rm *RecordManager) FindRecordByNameAndUser(username, name string) (*Record, error)
- func (rm *RecordManager) FindRecordsByZone(username, zoneName string) (*[]Record, error)
- func (rm *RecordManager) UpdateLatestIPFSHash(username, recordName, ipfsHash string) (*Record, error)
- type SwarmDetails
- type Upload
- type UploadManager
- func (um *UploadManager) CalculateRefundCost(upload *Upload, now time.Time) (float64, error)
- func (um *UploadManager) ExtendGarbageCollectionPeriod(username, hash, network string, holdTimeInMonths int) error
- func (um *UploadManager) FindUploadByHashAndNetwork(hash, networkName string) (*Upload, error)
- func (um *UploadManager) FindUploadByHashAndUserAndNetwork(username, hash, networkName string) (*Upload, error)
- func (um *UploadManager) FindUploadsByHash(hash string) ([]Upload, error)
- func (um *UploadManager) FindUploadsByNetwork(networkName string) ([]Upload, error)
- func (um *UploadManager) GetUploadByHashForUser(hash string, username string) ([]Upload, error)
- func (um *UploadManager) GetUploads() ([]Upload, error)
- func (um *UploadManager) GetUploadsForUser(username string) ([]Upload, error)
- func (um *UploadManager) NewUpload(contentHash, uploadType string, opts UploadOptions) (*Upload, error)
- func (um *UploadManager) RemovePin(username, hash, network string) error
- func (um *UploadManager) Search(username, fileName string) ([]Upload, error)
- func (um *UploadManager) UpdateUpload(holdTimeInMonths int64, username, contentHash, networkName string) (*Upload, error)
- type UploadOptions
- type Usage
- type UsageManager
- func (bm *UsageManager) CanCreateKey(username string) error
- func (bm *UsageManager) CanPublishIPNS(username string) error
- func (bm *UsageManager) CanPublishPubSub(username string) error
- func (bm *UsageManager) ClaimENSName(username string) error
- func (bm *UsageManager) FindByUserName(username string) (*Usage, error)
- func (bm *UsageManager) GetUploadPricePerGB(username string) (float64, error)
- func (bm *UsageManager) IncrementIPNSUsage(username string, count int64) error
- func (bm *UsageManager) IncrementKeyCount(username string, count int64) error
- func (bm *UsageManager) IncrementPubSubUsage(username string, count int64) error
- func (bm *UsageManager) NewUsageEntry(username string, tier DataUsageTier) (*Usage, error)
- func (bm *UsageManager) ReduceDataUsage(username string, uploadSizeBytes uint64) error
- func (bm *UsageManager) ReduceKeyCount(username string, count int64) error
- func (bm *UsageManager) ResetCounts(username string) error
- func (bm *UsageManager) UnclaimENSName(username string) error
- func (bm *UsageManager) UpdateDataUsage(username string, uploadSizeBytes uint64) error
- func (bm *UsageManager) UpdateTier(username string, tier DataUsageTier) error
- type User
- type UserManager
- func (um *UserManager) AddCredits(username string, credits float64) (*User, error)
- func (um *UserManager) AddIPFSKeyForUser(username, keyName, keyID string) error
- func (um *UserManager) AddIPFSNetworkForUser(username, networkName string) error
- func (um *UserManager) ChangePassword(username, currentPassword, newPassword string) (bool, error)
- func (um *UserManager) CheckIfAdmin(username string) (bool, error)
- func (um *UserManager) CheckIfKeyOwnedByUser(username, keyName string) (bool, error)
- func (um *UserManager) CheckIfUserAccountEnabled(username string) (bool, error)
- func (um *UserManager) CheckIfUserHasAccessToNetwork(username, networkName string) (bool, error)
- func (um *UserManager) ComparePlaintextPasswordToHash(usernameOrEmail, password string) (bool, error)
- func (um *UserManager) FindByEmail(email string) (*User, error)
- func (um *UserManager) FindByUserName(username string) (*User, error)
- func (um *UserManager) GenerateEmailVerificationToken(username string) (*User, error)
- func (um *UserManager) GetCreditsForUser(username string) (float64, error)
- func (um *UserManager) GetCustomerObjectHash(username string) (string, error)
- func (um *UserManager) GetKeyIDByName(username, keyName string) (string, error)
- func (um *UserManager) GetKeysForUser(username string) (map[string][]string, error)
- func (um *UserManager) GetPrivateIPFSNetworksForUser(username string) ([]string, error)
- func (um *UserManager) NewUserAccount(username, password, email string) (*User, error)
- func (um *UserManager) RemoveCredits(username string, credits float64) (*User, error)
- func (um *UserManager) RemoveIPFSKeyForUser(username, keyName, keyID string) error
- func (um *UserManager) RemoveIPFSNetworkForUser(username, networkName string) error
- func (um *UserManager) ResetPassword(username string) (string, error)
- func (um *UserManager) SignIn(usernameOrEmail, password string) (bool, error)
- func (um *UserManager) ToggleAdmin(username string) (bool, error)
- func (um *UserManager) UpdateCustomerObjectHash(username, newHash string) error
- func (um *UserManager) ValidateEmailVerificationToken(username, token string) (*User, error)
- type Zone
- type ZoneManager
- func (zm *ZoneManager) AddRecordForZone(zoneName, recordName, username string) (*Zone, error)
- func (zm *ZoneManager) CheckIfRecordExistsInZone(zoneName, recordName, username string) (bool, error)
- func (zm *ZoneManager) FindZoneByNameAndUser(name, username string) (*Zone, error)
- func (zm *ZoneManager) NewZone(username, name, managerPK, zonePK, latestIPFSHash string) (*Zone, error)
- func (zm *ZoneManager) UpdateLatestIPFSHashForZone(name, username, hash string) (*Zone, error)
Constants ¶
const ( // ErrShorterGCD is an error triggered when updating to update an upload for a user // with a hold time that would result in a shorter garbage collection date ErrShorterGCD = "upload would not extend garbage collection date so there is no need to process" // ErrAlreadyExistingUpload is an error triggered when attempting to insert a new row into the database // for a content that already exists in the database for a user. This means you should be using the UpdateUpload // function to allow for updating garbage collection dates. ErrAlreadyExistingUpload = "the content you are inserting into the database already exists, please use the UpdateUpload function" )
Variables ¶
var ( // Free is what every signed up user is automatically registered as // Restrictions of free: // * No on-demand data encryption // * 3GB/month max // * IPNS limit of 5, with no automatic republishes // * 5 keys Free DataUsageTier = "free" // Paid is the non-free tier of Temporal // Maximum data-limit is 1TB/month // * on-demand data encryption Paid DataUsageTier = "paid" // Partner is for partners of RTrade // partners have 100GB/month free // * on-demand data encryption // * 0.16GB/month after 100GB limit Partner DataUsageTier = "partner" // WhiteLabeled is a special billing system // that enables resellers, and customized // billing scenarios without having to modify much code WhiteLabeled DataUsageTier = "white-labeled" // FreeUploadLimit is the maximum data usage for free accounts // Currrently set to 3GB FreeUploadLimit = 3 * datasize.GB.Bytes() // NonFreeUploadLimit is the maximum data usage for non-free accounts // Currently set to 1000TB or 1PB. // We dont impose a usage limit to non-free accounts // but since usage limit checking is needed for free // accounts, we set an artificial limit. NonFreeUploadLimit = datasize.TB.Bytes() * 1000 // FreeKeyLimit defines how many keys free accounts can create FreeKeyLimit int64 = 5 // FreePubSubLimit defines how many pubsub messages free accounts can send FreePubSubLimit int64 = 100 // FreeIPNSLimit defines how many ipns records free accounts can publish FreeIPNSLimit int64 = 5 // PaidKeyLimit defines how many keys plus accounts can create PaidKeyLimit int64 = 150 // PaidPubSubLimit defines how many pubsub messages plus accounts can send PaidPubSubLimit int64 = 15000 // PaidIPNSRecordLimit defines how many ipns records plus accounts can publish PaidIPNSRecordLimit int64 = 150 // PartnerKeyLimit defines how many keys partner accounts can create PartnerKeyLimit int64 = 200 // PartnerPubSubLimit defines how many pubsub messages partner accounts can send PartnerPubSubLimit int64 = 20000 // PartnerIPNSLimit defines how many ipns records partner accounts can publish PartnerIPNSLimit int64 = 200 // WhiteLabeledLimits is a generalized limitation for white-labeled accounts WhiteLabeledLimits int64 = 2147483647 )
var AdminAddress = "0xC6C35f43fDD71f86a2D8D4e3cA1Ce32564c38bd9"
AdminAddress is the eth address of the admin account
var (
// EmptyCustomerObjectHash is an empty customer object published to ipfs
EmptyCustomerObjectHash = "zdpuAnUGSDoNQoHQ2jpjhPePHEvg26mYLsAAGxr4jkzCWUpde"
)
Functions ¶
This section is empty.
Types ¶
type APIDetails ¶
type APIDetails struct {
AllowedOrigin string
}
APIDetails provides data about IPFS API connection
type BillingItem ¶ added in v2.5.0
type BillingItem struct { User string `json:"user"` // this returns the number of new uploads from within the query range NumberOfNewUploads int `json:"number_of_new_uploads"` // this is the total data used by the account CurrentDataUsedBytes uint64 `json:"total_data_used_bytes"` }
BillingItem is an individual user's billing history
type BillingReport ¶ added in v2.5.0
type BillingReport struct { OrgName string `json:"org_name"` Items []BillingItem `json:"items"` // amount owed in USD AmountDue float64 `json:"amount_due"` // the unix (nano) timestamp the report was finalized at Time int64 `json:"time"` }
BillingReport contains a summary of an organizations entire active user base in the last 30 days along with the USD value currently owned by the account
type DataUsageTier ¶
type DataUsageTier string
DataUsageTier is a type of usage tier which governs the price per gb ratio
func (DataUsageTier) PricePerGB ¶
func (d DataUsageTier) PricePerGB() float64
PricePerGB returns the price per gb of a usage tier
func (DataUsageTier) PricePerGBPerHour ¶ added in v2.7.4
func (d DataUsageTier) PricePerGBPerHour() float64
PricePerGBPerHour returns the price per gb per hour we use an approximation of 730 hours
func (DataUsageTier) String ¶
func (d DataUsageTier) String() string
String returns the value of DataUsageTier as a string
func (DataUsageTier) ZeroCreditRefunds ¶ added in v2.7.4
func (d DataUsageTier) ZeroCreditRefunds() bool
ZeroCreditRefunds indicates whether this tier can never get refunds this either because they are free, or a tier such as whitelabelled which has a different billing system
type EncryptedUpload ¶
type EncryptedUpload struct { gorm.Model UserName string `gorm:"type:varchar(255)"` FileName string `gorm:"type:varchar(255)"` FileNameUpper string `gorm:"type:varchar(255)"` FileNameLower string `gorm:"type:varchar(255)"` NetworkName string `gorm:"type:varchar(255)"` IPFSHash string `gorm:"type:varchar(255)"` }
EncryptedUpload is an uploaded that has been encrypted by Temporal
type EncryptedUploadManager ¶
EncryptedUploadManager is used to manipulate encrypted uplaods
func NewEncryptedUploadManager ¶
func NewEncryptedUploadManager(db *gorm.DB) *EncryptedUploadManager
NewEncryptedUploadManager is used to generate our db helper
func (*EncryptedUploadManager) FindUploadsByUser ¶
func (ecm *EncryptedUploadManager) FindUploadsByUser(username string) (*[]EncryptedUpload, error)
FindUploadsByUser is used to find all uploads for a given user
func (*EncryptedUploadManager) NewUpload ¶
func (ecm *EncryptedUploadManager) NewUpload(username, filename, networname, ipfsHash string) (*EncryptedUpload, error)
NewUpload is used to store a new encrypted upload in the database
type HostedNetwork ¶
type HostedNetwork struct { ID uint `gorm:"primary_key"` CreatedAt time.Time UpdatedAt time.Time Name string `gorm:"unique;type:varchar(255)"` // Name of the network node Activated *time.Time // Activated represents the most recent activation, null if offline Disabled bool PeerKey string // Private key used to generate peerID for this network node // SwarmAddr is the address of swarm port. Slated for deprecation if HTTP path // support is added to the multiaddr spec and go-multiaddr SwarmAddr string `gorm:"type:varchar(255)"` // SwarmKey is the key used to connect to this peer SwarmKey string `gorm:"type:varchar(255)"` // Used to set Allowed-Origin headers on API requests APIAllowedOrigin string `gorm:"type:varchar(255)"` // Toggles whether gateway should be exposed through Nexus delegator GatewayPublic bool `gorm:"type:boolean"` // Peers to bootstrap node onto BootstrapPeerAddresses pq.StringArray `gorm:"type:text[]"` BootstrapPeerIDs pq.StringArray `gorm:"type:text[];column:bootstrap_peer_ids"` // Resources for deployed node ResourcesCPUs int ResourcesDiskGB int ResourcesMemoryGB int // Owner is the creator of the private network, and is allowed to invoke // administrative commands, such as network destruction. Owners pq.StringArray `gorm:"type:text[]"` // Users allowed to control this node. Includes API access. Users pq.StringArray `gorm:"type:text[]"` // these are the users to which this IPFS network connection applies to specified by eth address }
HostedNetwork is a private network for which we are responsible of the infrastructure
type HostedNetworkManager ¶
HostedNetworkManager is used to manipulate IPFS network models in the database
func NewHostedNetworkManager ¶
func NewHostedNetworkManager(db *gorm.DB) *HostedNetworkManager
NewHostedNetworkManager is used to initialize our database connection
func (*HostedNetworkManager) CreateHostedPrivateNetwork ¶
func (im *HostedNetworkManager) CreateHostedPrivateNetwork( name, swarmKey string, peers []string, access NetworkAccessOptions, ) (*HostedNetwork, error)
CreateHostedPrivateNetwork is used to store a new hosted private network in the database
func (*HostedNetworkManager) Delete ¶
func (im *HostedNetworkManager) Delete(name string) error
Delete is used to remove a network from the database
func (*HostedNetworkManager) GetAPIDetails ¶
func (im *HostedNetworkManager) GetAPIDetails(network string) (*APIDetails, error)
GetAPIDetails is used to retrieve data about IPFS API connection
func (*HostedNetworkManager) GetNetworkByName ¶
func (im *HostedNetworkManager) GetNetworkByName(name string) (*HostedNetwork, error)
GetNetworkByName is used to retrieve a network from the database based off of its name
func (*HostedNetworkManager) GetOfflineNetworks ¶
func (im *HostedNetworkManager) GetOfflineNetworks(disabled bool) ([]*HostedNetwork, error)
GetOfflineNetworks returns all currently offline networks
func (*HostedNetworkManager) GetSwarmDetails ¶
func (im *HostedNetworkManager) GetSwarmDetails(network string) (*SwarmDetails, error)
GetSwarmDetails is used to retrieve data about IPFS swarm connection
func (*HostedNetworkManager) SaveNetwork ¶
func (im *HostedNetworkManager) SaveNetwork(n *HostedNetwork) error
SaveNetwork saves the given HostedNetwork in the database
func (*HostedNetworkManager) UpdateNetworkByName ¶
func (im *HostedNetworkManager) UpdateNetworkByName(name string, attrs map[string]interface{}) error
UpdateNetworkByName updates the given network with given attributes
type IPNS ¶
type IPNS struct { gorm.Model Sequence int64 `gorm:"type:integer"` // the ipns hash, is the peer id of the peer used to sign the entry IPNSHash string `gorm:"type:varchar(255);unique"` // List of content hashes this IPNS entry has pointed to IPFSHashes pq.StringArray `gorm:"type:text[]"` CurrentIPFSHash string `gorm:"type:varchar(255)"` LifeTime string `gorm:"type:varchar(255)"` TTL string `gorm:"type:varchar(255)"` Key string `gorm:"type:varchar(255)"` NetworkName string `gorm:"type:varchar(255)"` UserName string `gorm:"type:varchar(255)"` }
IPNS will hold all of the IPNS entries in our system
type IpnsManager ¶
IpnsManager is used for manipulating IPNS records in our database
func NewIPNSManager ¶
func NewIPNSManager(db *gorm.DB) *IpnsManager
NewIPNSManager is used to generate our model manager
func (*IpnsManager) CreateEntry ¶
func (im *IpnsManager) CreateEntry(ipnsHash, ipfsHash, key, networkName, username string, lifetime, ttl time.Duration) (*IPNS, error)
CreateEntry is used to create a brand new IPNS entry in our database
func (*IpnsManager) FindAll ¶
func (im *IpnsManager) FindAll() ([]IPNS, error)
FindAll is used to find all IPNS records
func (*IpnsManager) FindByIPNSHash ¶
func (im *IpnsManager) FindByIPNSHash(ipnsHash string) (*IPNS, error)
FindByIPNSHash is used to find an IPNS record from our database searching for the public key hash of the key that was used to pulish a record
func (*IpnsManager) FindByUserName ¶
func (im *IpnsManager) FindByUserName(username string) (*[]IPNS, error)
FindByUserName is used to find all IPNS entries published by a given user
func (*IpnsManager) UpdateIPNSEntry ¶
func (im *IpnsManager) UpdateIPNSEntry(ipnsHash, ipfsHash, networkName, username string, lifetime, ttl time.Duration) (*IPNS, error)
UpdateIPNSEntry is used to update an already existing IPNS entry, creating a no record matching the hash exists
type NetworkAccessOptions ¶
type NetworkAccessOptions struct { Owner string Users []string APIAllowedOrigin string PublicGateway bool }
NetworkAccessOptions configures access to a hosted private network
type OrgManager ¶ added in v2.5.0
OrgManager is an organization model manager
func NewOrgManager ¶ added in v2.5.0
func NewOrgManager(db *gorm.DB) *OrgManager
NewOrgManager instantiates an OrgManager
func (*OrgManager) DecreaseAmountOwed ¶ added in v2.5.0
func (om *OrgManager) DecreaseAmountOwed(name string, amount float64) error
DecreaseAmountOwed decreases the amount owed by this account
func (*OrgManager) FindByName ¶ added in v2.5.0
func (om *OrgManager) FindByName(name string) (*Organization, error)
FindByName finds an organization by name
func (*OrgManager) GenerateBillingReport ¶ added in v2.5.0
func (om *OrgManager) GenerateBillingReport(name string, minTime, maxTime time.Time) (*BillingReport, error)
GenerateBillingReport is used to generate a billing report object for an organization's entire user base in the last 30 days. Care must be taken so that only the organization owner may interact with this function, and is it returns sensitive information
func (*OrgManager) GetOrgUsers ¶ added in v2.5.0
func (om *OrgManager) GetOrgUsers(name string) ([]string, error)
GetOrgUsers is used toreturn the registered users an organization has
func (*OrgManager) GetTotalStorageUsed ¶ added in v2.5.0
func (om *OrgManager) GetTotalStorageUsed(name string) (uint64, error)
GetTotalStorageUsed returns the total storage in bytes consumed by the organization.
func (*OrgManager) GetUserUploads ¶ added in v2.7.0
func (om *OrgManager) GetUserUploads(orgName, username string) ([]Upload, error)
GetUserUploads is used to return all uploads from the organization user
func (*OrgManager) IncreaseAmountOwed ¶ added in v2.5.0
func (om *OrgManager) IncreaseAmountOwed(name string, amount float64) error
IncreaseAmountOwed increases the amount owed by this account
func (*OrgManager) NewOrganization ¶ added in v2.5.0
func (om *OrgManager) NewOrganization(name, owner string) (*Organization, error)
NewOrganization is used to create a new organization
func (*OrgManager) RegisterOrgUser ¶ added in v2.5.0
func (om *OrgManager) RegisterOrgUser( orgName, username, password, email string, ) (*User, error)
RegisterOrgUser registers an organization user
type Organization ¶ added in v2.5.0
type Organization struct { gorm.Model // the name of the organization Name string `gorm:"type:varchar(255);unique"` // the corresponding temporal user account that manages this org AccountOwner string `gorm:"type:varchar(255);unique"` // the usd value owed by the organization AmountOwed float64 `gorm:"type:float"` // the user accounts who have signed up under this organization RegisteredUsers pq.StringArray `gorm:"type:text[];column:registered_users"` }
Organization represents a company using white-labeled Temporal
type PaymentManager ¶
PaymentManager is used to interact with payment information in our database
func NewPaymentManager ¶
func NewPaymentManager(db *gorm.DB) *PaymentManager
NewPaymentManager is used to generate our payment manager helper
func (*PaymentManager) ConfirmPayment ¶
func (pm *PaymentManager) ConfirmPayment(txHash string) (*Payments, error)
ConfirmPayment is used to mark a payment as confirmed
func (*PaymentManager) FindPaymentByNumber ¶
func (pm *PaymentManager) FindPaymentByNumber(username string, number int64) (*Payments, error)
FindPaymentByNumber is used to find a payment by its payment number
func (*PaymentManager) FindPaymentByTxHash ¶
func (pm *PaymentManager) FindPaymentByTxHash(txHash string) (*Payments, error)
FindPaymentByTxHash is used to find a payment by its tx hash
func (*PaymentManager) GetLatestPaymentNumber ¶
func (pm *PaymentManager) GetLatestPaymentNumber(username string) (int64, error)
GetLatestPaymentNumber is used to get the latest payment number for a user
func (*PaymentManager) NewPayment ¶
func (pm *PaymentManager) NewPayment(number int64, depositAddress string, txHash string, usdValue, chargeAmount float64, blockchain string, paymentType string, username string) (*Payments, error)
NewPayment is used to create a payment in our database
func (*PaymentManager) UpdatePaymentTxHash ¶
func (pm *PaymentManager) UpdatePaymentTxHash(username, txHash string, number int64) (*Payments, error)
UpdatePaymentTxHash UpdatePaymentTxHash is used to update the tx hash of a payment
type Payments ¶
type Payments struct { gorm.Model Number int64 `gorm:"type:integer"` DepositAddress string `gorm:"type:varchar(255)"` TxHash string `gorm:"type:varchar(255);unique"` USDValue float64 `gorm:"type:float"` // USDValue is also a "Credit" value, since 1 USD -> 1 Credit ChargeAmount float64 `gorm:"type:float"` Blockchain string `gorm:"type:varchar(255)"` Type string `gorm:"type:varchar(255)"` // ETH, RTC, XMR, BTC, LTC UserName string `gorm:"type:varchar(255)"` Confirmed bool `gorm:"type:varchar(255)"` }
Payments is our payment model
type Record ¶
type Record struct { gorm.Model UserName string `gorm:"type:varchar(255)"` Name string `gorm:"type:varchar(255)"` RecordKeyName string `gorm:"type:varchar(255)"` LatestIPFSHash string `gorm:"type:varchar(255)"` ZoneName string `gorm:"type:varchar(255)"` MetaData interface{} `gorm:"type:text"` // we need to parse this to a "string json" }
Record is an entry within a tns zone
type RecordManager ¶
RecordManager is used to manipulate records in our db
func NewRecordManager ¶
func NewRecordManager(db *gorm.DB) *RecordManager
NewRecordManager is used to generate our record manager
func (*RecordManager) AddRecord ¶
func (rm *RecordManager) AddRecord(username, recordName, recordKeyName, zoneName string, metadata map[string]interface{}) (*Record, error)
AddRecord is used to save a record to our database
func (*RecordManager) FindRecordByNameAndUser ¶
func (rm *RecordManager) FindRecordByNameAndUser(username, name string) (*Record, error)
FindRecordByNameAndUser is used to search fro a record by name and user
func (*RecordManager) FindRecordsByZone ¶
func (rm *RecordManager) FindRecordsByZone(username, zoneName string) (*[]Record, error)
FindRecordsByZone is used to find records by zone
func (*RecordManager) UpdateLatestIPFSHash ¶
func (rm *RecordManager) UpdateLatestIPFSHash(username, recordName, ipfsHash string) (*Record, error)
UpdateLatestIPFSHash is used to update the latest IPFS hash that can be used to examine this record
type SwarmDetails ¶
SwarmDetails provides data about IPFS swarm connection
type Upload ¶
type Upload struct { gorm.Model Hash string `gorm:"type:varchar(255);not null;"` Type string `gorm:"type:varchar(255);not null;"` // file, pin NetworkName string `gorm:"type:varchar(255)"` HoldTimeInMonths int64 `gorm:"type:integer;not null;"` UserName string `gorm:"type:varchar(255);not null;"` GarbageCollectDate time.Time Encrypted bool `gorm:"type:bool"` FileName string `gorm:"type:varchar(255)"` FileNameLowerCase string `gorm:"type:varchar(255)"` FileNameUpperCase string `gorm:"type:varchar(255)"` Extension string `gorm:"type:varchar(255)"` Size int64 `gorm:"type:bigint"` // upload size in bytes Directory bool `gorm:"type:bool;default:false"` }
Upload is a file or pin based upload to temporal
type UploadManager ¶
UploadManager is used to manipulate upload objects in the database
func NewUploadManager ¶
func NewUploadManager(db *gorm.DB) *UploadManager
NewUploadManager is used to generate an upload manager interface
func (*UploadManager) CalculateRefundCost ¶ added in v2.7.4
CalculateRefundCost returns the amount of credits to refund the user when they invoke pinRM
func (*UploadManager) ExtendGarbageCollectionPeriod ¶
func (um *UploadManager) ExtendGarbageCollectionPeriod(username, hash, network string, holdTimeInMonths int) error
ExtendGarbageCollectionPeriod is used to extend the garbage collection period for a particular upload
func (*UploadManager) FindUploadByHashAndNetwork ¶
func (um *UploadManager) FindUploadByHashAndNetwork(hash, networkName string) (*Upload, error)
FindUploadByHashAndNetwork is used to search for an upload by its hash, and the network it was stored on
func (*UploadManager) FindUploadByHashAndUserAndNetwork ¶
func (um *UploadManager) FindUploadByHashAndUserAndNetwork(username, hash, networkName string) (*Upload, error)
FindUploadByHashAndUserAndNetwork is used to look for an upload based off its hash, user, and network
func (*UploadManager) FindUploadsByHash ¶
func (um *UploadManager) FindUploadsByHash(hash string) ([]Upload, error)
FindUploadsByHash is used to return all instances of uploads matching the given hash
func (*UploadManager) FindUploadsByNetwork ¶
func (um *UploadManager) FindUploadsByNetwork(networkName string) ([]Upload, error)
FindUploadsByNetwork is used to find all uploads corresponding to a given network
func (*UploadManager) GetUploadByHashForUser ¶
func (um *UploadManager) GetUploadByHashForUser(hash string, username string) ([]Upload, error)
GetUploadByHashForUser is used to retrieve the last (most recent) upload for a user
func (*UploadManager) GetUploads ¶
func (um *UploadManager) GetUploads() ([]Upload, error)
GetUploads is used to return all uploads
func (*UploadManager) GetUploadsForUser ¶
func (um *UploadManager) GetUploadsForUser(username string) ([]Upload, error)
GetUploadsForUser is used to retrieve all uploads by a user name
func (*UploadManager) NewUpload ¶
func (um *UploadManager) NewUpload(contentHash, uploadType string, opts UploadOptions) (*Upload, error)
NewUpload is used to create a new upload in the database
func (*UploadManager) RemovePin ¶ added in v2.7.4
func (um *UploadManager) RemovePin(username, hash, network string) error
RemovePin allows removing a pin and refunding extra data costs
func (*UploadManager) Search ¶ added in v2.7.3
func (um *UploadManager) Search(username, fileName string) ([]Upload, error)
Search is used return all uploads matching the fileName
To search for all uploads that start with the name `dog` provide the `dog%` query. To search for all uplodas with the name `dog` somewhere in the filename, provide `%dog%` All postgresql ruules for LIKE searches apply
func (*UploadManager) UpdateUpload ¶
func (um *UploadManager) UpdateUpload(holdTimeInMonths int64, username, contentHash, networkName string) (*Upload, error)
UpdateUpload is used to update the garbage collection time for an already existing upload
type UploadOptions ¶
type UploadOptions struct { NetworkName string Username string FileName string HoldTimeInMonths int64 Size int64 Encrypted bool Directory bool }
UploadOptions is used to configure an upload
type Usage ¶
type Usage struct { gorm.Model UserName string `gorm:"type:varchar(255);unique"` // keeps track of the max monthly upload limit for the user MonthlyDataLimitBytes uint64 `gorm:"type:numeric;default:0"` // keeps track of the current monthyl upload limit used CurrentDataUsedBytes uint64 `gorm:"type:numeric;default:0"` // keeps track of how many IPNS records the user has published IPNSRecordsPublished int64 `gorm:"type:integer;default:0"` // keeps track of how many ipns records the user is allowed to publish IPNSRecordsAllowed int64 `gorm:"type:integer;default:0"` // keeps track of how many messages the user has sent PubSubMessagesSent int64 `gorm:"type:integer;default:0"` // keeps track of the number of pubsub messages a user is allowed to send PubSubMessagesAllowed int64 `gorm:"type:integer;default:0"` // keeps track of how many keys the user has created KeysCreated int64 `gorm:"type:integer;default:0"` // keeps track of how many keys the user is allowed to create KeysAllowed int64 `gorm:"type:integer;default:0"` // keeps track of the tier the user belongs to Tier DataUsageTier `gorm:"type:varchar(255)"` // indicates whether or not the user has claimed their ens name ClaimedENSName bool `gorm:"type:boolean"` }
Usage is used to handle Usage of Temporal accounts
type UsageManager ¶
UsageManager is used to manage Usage models
func NewUsageManager ¶
func NewUsageManager(db *gorm.DB) *UsageManager
NewUsageManager is used to instantiate a Usage manager
func (*UsageManager) CanCreateKey ¶
func (bm *UsageManager) CanCreateKey(username string) error
CanCreateKey is used to check if a user can create an ipfs key
func (*UsageManager) CanPublishIPNS ¶
func (bm *UsageManager) CanPublishIPNS(username string) error
CanPublishIPNS is used to check if a user can publish IPNS records
func (*UsageManager) CanPublishPubSub ¶
func (bm *UsageManager) CanPublishPubSub(username string) error
CanPublishPubSub is used to check if a user can publish pubsub messages
func (*UsageManager) ClaimENSName ¶ added in v2.6.2
func (bm *UsageManager) ClaimENSName(username string) error
ClaimENSName is used to claim the users ens name
func (*UsageManager) FindByUserName ¶
func (bm *UsageManager) FindByUserName(username string) (*Usage, error)
FindByUserName is used to find a Usage model by the associated username
func (*UsageManager) GetUploadPricePerGB ¶
func (bm *UsageManager) GetUploadPricePerGB(username string) (float64, error)
GetUploadPricePerGB is used to get the upload price per gb for a user allows us to specify whether the payment
func (*UsageManager) IncrementIPNSUsage ¶
func (bm *UsageManager) IncrementIPNSUsage(username string, count int64) error
IncrementIPNSUsage is used to increment the ipns record publish counter
func (*UsageManager) IncrementKeyCount ¶
func (bm *UsageManager) IncrementKeyCount(username string, count int64) error
IncrementKeyCount is used to increment the key created counter
func (*UsageManager) IncrementPubSubUsage ¶
func (bm *UsageManager) IncrementPubSubUsage(username string, count int64) error
IncrementPubSubUsage is used to increment the pubsub publish counter
func (*UsageManager) NewUsageEntry ¶
func (bm *UsageManager) NewUsageEntry(username string, tier DataUsageTier) (*Usage, error)
NewUsageEntry is used to create a new usage entry in our database if tier is free, limit to 3GB monthly otherwise set to 1TB
func (*UsageManager) ReduceDataUsage ¶
func (bm *UsageManager) ReduceDataUsage(username string, uploadSizeBytes uint64) error
ReduceDataUsage is used to reduce a users current data used. This is used in cases where processing within the queue system fails, and we need to reset their data usage
func (*UsageManager) ReduceKeyCount ¶
func (bm *UsageManager) ReduceKeyCount(username string, count int64) error
ReduceKeyCount is used to reduce the number of keys a user has created
func (*UsageManager) ResetCounts ¶
func (bm *UsageManager) ResetCounts(username string) error
ResetCounts is used to reset monthly usage counts. This does not apply to keys created as that is a fixed limit. Instead, it applies to rate-limited features as as IPNS record publishing, and sending of PubSub messages
func (*UsageManager) UnclaimENSName ¶ added in v2.6.2
func (bm *UsageManager) UnclaimENSName(username string) error
UnclaimENSName is used to unclaim a users ens name
func (*UsageManager) UpdateDataUsage ¶
func (bm *UsageManager) UpdateDataUsage(username string, uploadSizeBytes uint64) error
UpdateDataUsage is used to update the users' data usage amount If the account is non free, and the upload pushes their total monthly usage above the tier limit, they will be upgraded to the next tier to receive the discounted price the discounted price will apply on subsequent uploads. If the 1TB maximum monthly limit is hit, then we throw an error
func (*UsageManager) UpdateTier ¶
func (bm *UsageManager) UpdateTier(username string, tier DataUsageTier) error
UpdateTier is used to update the Usage tier associated with an account
type User ¶
type User struct { gorm.Model UserName string `gorm:"type:varchar(255);unique"` EmailAddress string `gorm:"type:varchar(255);unique"` AccountEnabled bool `gorm:"type:boolean"` EmailEnabled bool `gorm:"type:boolean"` EmailVerificationToken string `gorm:"type:varchar(255)"` AdminAccess bool `gorm:"type:boolean"` HashedPassword string `gorm:"type:varchar(255)"` Free bool `gorm:"type:boolean"` Credits float64 `gorm:"type:float;default:0"` CustomerObjectHash string `gorm:"type:varchar(255)"` // the organization if any this user belongs to otherwise empty string. // A non-empty string changes how the backend processes billing to do // organization based billing, not user-account billing Organization string `gorm:"type:varchar(255)"` // IPFSKeyNames is an array of IPFS key name this user has created IPFSKeyNames pq.StringArray `gorm:"type:text[];column:ipfs_key_names"` // IPFSKeyIDs is an array of public key hashes for IPFS keys this user has created IPFSKeyIDs pq.StringArray `gorm:"type:text[];column:ipfs_key_ids"` // IPFSNetworkNames is an array of private IPFS networks this user has access to IPFSNetworkNames pq.StringArray `gorm:"type:text[];column:ipfs_network_names"` }
User is our user model for anyone who signs up with Temporal
type UserManager ¶
UserManager is our helper to interact with our database
func NewUserManager ¶
func NewUserManager(db *gorm.DB) *UserManager
NewUserManager is used to generate our user manager helper
func (*UserManager) AddCredits ¶
func (um *UserManager) AddCredits(username string, credits float64) (*User, error)
AddCredits is used to add credits to a user account
func (*UserManager) AddIPFSKeyForUser ¶
func (um *UserManager) AddIPFSKeyForUser(username, keyName, keyID string) error
AddIPFSKeyForUser is used to add a key to a user
func (*UserManager) AddIPFSNetworkForUser ¶
func (um *UserManager) AddIPFSNetworkForUser(username, networkName string) error
AddIPFSNetworkForUser is used to update a users allowed private ipfs networks
func (*UserManager) ChangePassword ¶
func (um *UserManager) ChangePassword(username, currentPassword, newPassword string) (bool, error)
ChangePassword is used to change a users password
func (*UserManager) CheckIfAdmin ¶
func (um *UserManager) CheckIfAdmin(username string) (bool, error)
CheckIfAdmin is used to check if an account is an administrator
func (*UserManager) CheckIfKeyOwnedByUser ¶
func (um *UserManager) CheckIfKeyOwnedByUser(username, keyName string) (bool, error)
CheckIfKeyOwnedByUser is used to check if a key is owned by a user
func (*UserManager) CheckIfUserAccountEnabled ¶
func (um *UserManager) CheckIfUserAccountEnabled(username string) (bool, error)
CheckIfUserAccountEnabled is used to check if a user account is enabled
func (*UserManager) CheckIfUserHasAccessToNetwork ¶
func (um *UserManager) CheckIfUserHasAccessToNetwork(username, networkName string) (bool, error)
CheckIfUserHasAccessToNetwork is used to check if a user has access to a private ipfs network
func (*UserManager) ComparePlaintextPasswordToHash ¶
func (um *UserManager) ComparePlaintextPasswordToHash(usernameOrEmail, password string) (bool, error)
ComparePlaintextPasswordToHash is a helper method used to validate a users password
func (*UserManager) FindByEmail ¶
func (um *UserManager) FindByEmail(email string) (*User, error)
FindByEmail is used to find a particular user based on their email address
func (*UserManager) FindByUserName ¶
func (um *UserManager) FindByUserName(username string) (*User, error)
FindByUserName is used to find a user by their username
func (*UserManager) GenerateEmailVerificationToken ¶
func (um *UserManager) GenerateEmailVerificationToken(username string) (*User, error)
GenerateEmailVerificationToken is used to generate a token we use to validate that the user actually owns the email they are signing up with
func (*UserManager) GetCreditsForUser ¶
func (um *UserManager) GetCreditsForUser(username string) (float64, error)
GetCreditsForUser is used to get the user's current credits
func (*UserManager) GetCustomerObjectHash ¶
func (um *UserManager) GetCustomerObjectHash(username string) (string, error)
GetCustomerObjectHash is used to retrieve the object hash of a customer
func (*UserManager) GetKeyIDByName ¶
func (um *UserManager) GetKeyIDByName(username, keyName string) (string, error)
GetKeyIDByName is used to get the ID of a key by searching for its name
func (*UserManager) GetKeysForUser ¶
func (um *UserManager) GetKeysForUser(username string) (map[string][]string, error)
GetKeysForUser is used to get a mapping of a users keys
func (*UserManager) GetPrivateIPFSNetworksForUser ¶
func (um *UserManager) GetPrivateIPFSNetworksForUser(username string) ([]string, error)
GetPrivateIPFSNetworksForUser is used to get a list of allowed private ipfs networks for a user
func (*UserManager) NewUserAccount ¶
func (um *UserManager) NewUserAccount(username, password, email string) (*User, error)
NewUserAccount is used to create a new user account
func (*UserManager) RemoveCredits ¶
func (um *UserManager) RemoveCredits(username string, credits float64) (*User, error)
RemoveCredits is used to remove credits from a users balance
func (*UserManager) RemoveIPFSKeyForUser ¶
func (um *UserManager) RemoveIPFSKeyForUser(username, keyName, keyID string) error
RemoveIPFSKeyForUser is used to remove a given key name and its id from the users available keys they have created.
func (*UserManager) RemoveIPFSNetworkForUser ¶
func (um *UserManager) RemoveIPFSNetworkForUser(username, networkName string) error
RemoveIPFSNetworkForUser is used to remove a configured ipfs network from the users authorized networks
func (*UserManager) ResetPassword ¶
func (um *UserManager) ResetPassword(username string) (string, error)
ResetPassword is used to reset a user's password if they forgot it
func (*UserManager) SignIn ¶
func (um *UserManager) SignIn(usernameOrEmail, password string) (bool, error)
SignIn is used to authenticate a user, and check if their account is enabled. Returns bool on succesful login, or false with an error on failure
func (*UserManager) ToggleAdmin ¶
func (um *UserManager) ToggleAdmin(username string) (bool, error)
ToggleAdmin toggles the admin permissions of given user
func (*UserManager) UpdateCustomerObjectHash ¶
func (um *UserManager) UpdateCustomerObjectHash(username, newHash string) error
UpdateCustomerObjectHash is used to update the customer object hash associated with the user
func (*UserManager) ValidateEmailVerificationToken ¶
func (um *UserManager) ValidateEmailVerificationToken(username, token string) (*User, error)
ValidateEmailVerificationToken is used to validate an email token to enable email access
type Zone ¶
type Zone struct { gorm.Model UserName string `gorm:"type:varchar(255)"` Name string `gorm:"type:varchar(255)"` ManagerPublicKeyName string `gorm:"type:varchar(255)"` ZonePublicKeyName string `gorm:"type:varchar(255)"` LatestIPFSHash string `gorm:"type:varchar(255)"` RecordNames pq.StringArray `gorm:"type:text[]"` }
Zone is a TNS zone
type ZoneManager ¶
ZoneManager is used to manipulate zone entries in the database
func NewZoneManager ¶
func NewZoneManager(db *gorm.DB) *ZoneManager
NewZoneManager is used to generate our zone manager helper to interact with the db
func (*ZoneManager) AddRecordForZone ¶
func (zm *ZoneManager) AddRecordForZone(zoneName, recordName, username string) (*Zone, error)
AddRecordForZone is used to add a record to a zone
func (*ZoneManager) CheckIfRecordExistsInZone ¶
func (zm *ZoneManager) CheckIfRecordExistsInZone(zoneName, recordName, username string) (bool, error)
CheckIfRecordExistsInZone is used to check if a record exists in a particular zone
func (*ZoneManager) FindZoneByNameAndUser ¶
func (zm *ZoneManager) FindZoneByNameAndUser(name, username string) (*Zone, error)
FindZoneByNameAndUser is used to lookup a zone by name and user
func (*ZoneManager) NewZone ¶
func (zm *ZoneManager) NewZone(username, name, managerPK, zonePK, latestIPFSHash string) (*Zone, error)
NewZone is used to create a new zone in the database
func (*ZoneManager) UpdateLatestIPFSHashForZone ¶
func (zm *ZoneManager) UpdateLatestIPFSHashForZone(name, username, hash string) (*Zone, error)
UpdateLatestIPFSHashForZone is used to update the latest IPFS hash for a zone file