models

package
v0.0.0-...-d0a0e58 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SPOwnerRole = "sp_owner"
	ClientRole  = "data_client"
	SystemRole  = "system"
)
View Source
const (
	AdminRole = "admin"
)
View Source
const SectionDeals int64 = 500000

Variables

This section is empty.

Functions

func Models

func Models() []interface{}

Types

type AccessLog

type AccessLog struct {
	ID             uint           `gorm:"primarykey" json:"id"`
	CreatedAt      types.UnixTime `json:"created_at" gorm:"index"`
	Method         string         `json:"method" gorm:"size:32"`
	Uri            string         `json:"uri" gorm:"size:1024;index"`
	FullPath       string         `json:"full_path" gorm:"size:1024"`
	Cost           time.Duration  `json:"cost"`
	Ip             string         `json:"ip" gorm:"size:64"`
	Browser        string         `json:"browser" gorm:"size:32"`
	BrowserVersion string         `json:"browser_version" gorm:"size:64"`
	OS             string         `json:"os" gorm:"size:64"`
	Platform       string         `json:"platform" gorm:"size:32"`
	Mobile         bool           `json:"mobile"`
	Bot            bool           `json:"bot"`
	Status         int            `json:"status"`
}

type AdminUser

type AdminUser struct {
	Model
	Uid            uuid.UUID `json:"uid" gorm:"size:64;not null;uniqueIndex:uidx_adminuser_uid"`
	Name           string    `json:"name" gorm:"size:128;not null;uniqueIndex:uidx_adminuser_name"`
	HashedPassword string    `json:"password" gorm:"column:password;size:80"`
	Type           string    `json:"type" gorm:"size:32"` // "admin"
	Avatar         string    `json:"avatar" gorm:"size:1024"`
	Description    string    `json:"description" gorm:"size:2048"`
}

type ClientInfo

type ClientInfo struct {
	Model

	Uid                uuid.UUID       `json:"uid" gorm:"size:64;not null;uniqueIndex:uidx_cinfo_uid"`
	AddressId          string          `json:"address_id" gorm:"size:32;not null;uniqueIndex:uidx_cinfo_addrid"`
	StorageCapacity    decimal.Decimal `json:"storage_capacity" gorm:"type:decimal(50,0)"`
	StorageDeals       int64           `json:"storage_deals"`
	DataCap            decimal.Decimal `json:"data_cap" gorm:"type:decimal(50,0)"` // available datacap
	UsedDataCap        decimal.Decimal `json:"used_data_cap" gorm:"type:decimal(50,0);default:0"`
	VerifiedDeals      int64           `json:"verified_deals"`
	Bandwidth          string          `json:"bandwidth" gorm:"size:128"`
	MonthlyStorage     string          `json:"monthly_storage" gorm:"size:128"`
	UseCase            string          `json:"use_case" gorm:"size:128"`
	ServiceRequirement string          `json:"service_requirement" gorm:"size:1024"`
}

type ClientStats

type ClientStats struct {
	ID              uint            `gorm:"primarykey" json:"id"`
	CreatedAt       types.UnixTime  `json:"created_at"`
	UpdatedAt       types.UnixTime  `json:"updated_at"`
	SectionDealId   abi.DealID      `json:"section_deal_id" gorm:"not null;index;uniqueIndex:uidx_cs_cli_sec,priority:2"` // section statistical label
	Client          string          `json:"client" gorm:"size:32;not null;uniqueIndex:uidx_cs_cli_sec,priority:1"`
	UsedDataCap     decimal.Decimal `json:"used_data_cap" gorm:"type:decimal(50,0);default:0"`
	VerifiedDeals   int64           `json:"verified_deals" gorm:"default:0"`
	StorageCapacity decimal.Decimal `json:"storage_capacity" gorm:"type:decimal(50,0);default:0"`
	StorageDeals    int64           `json:"storage_deals" gorm:"default:0"`
}

type Deal

type Deal struct {
	DealId       abi.DealID `gorm:"primarykey"`
	PieceCid     string     `gorm:"size:255"`
	PieceSize    abi.PaddedPieceSize
	VerifiedDeal bool
	Client       string `gorm:"size:255;index"`
	Provider     string `gorm:"size:32;index"`

	// Label is an arbitrary client chosen label to apply to the deal
	Label string `gorm:"size:255"`

	// Nominal start epoch. Deal payment is linear between StartEpoch and EndEpoch,
	// with total amount StoragePricePerEpoch * (EndEpoch - StartEpoch).
	// Storage deal must appear in a sealed (proven) sector no later than StartEpoch,
	// otherwise it is invalid.
	StartEpoch           abi.ChainEpoch `gorm:"index"`
	EndEpoch             abi.ChainEpoch
	StoragePricePerEpoch decimal.Decimal `gorm:"type:decimal(50,0)"`

	ProviderCollateral decimal.Decimal `gorm:"type:decimal(50,0)"`
	ClientCollateral   decimal.Decimal `gorm:"type:decimal(50,0)"`

	SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector
	LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated
	SlashEpoch       abi.ChainEpoch // -1 if deal never slashed
}

type LoginInfo

type LoginInfo struct {
	ID             uint           `gorm:"primarykey" json:"id"`
	CreatedAt      types.UnixTime `json:"created_at"`
	Uid            uuid.UUID      `json:"uid" gorm:"size:64;index:idx_logininfo_uid"`
	Ip             string         `json:"ip" gorm:"size:64"`
	Browser        string         `json:"browser" gorm:"size:32"`
	BrowserVersion string         `json:"browser_version" gorm:"size:64"`
	OS             string         `json:"os" gorm:"size:64"`
	Platform       string         `json:"platform" gorm:"size:32"`
	Mobile         bool           `json:"mobile"`
	Bot            bool           `json:"bot"`
	Renewal        bool           `json:"renewal"` // Renewal, not a user login action
}

type Message

type Message struct {
	ID        uint           `json:"id" gorm:"primarykey"`
	CreatedAt types.UnixTime `json:"created_at" gorm:"index"`
	UpdatedAt types.UnixTime `json:"updated_at"`
	Sender    string         `json:"sender" gorm:"size:64;index:idx_msg_s_r,priority:1"`
	Recipient string         `json:"recipient" gorm:"size:64;index;index:idx_msg_s_r,priority:2"`
	Type      int8           `json:"type" gorm:"default:0;not null"` // 0:text message
	Content   string         `json:"content" gorm:"size:1024"`
	Checked   bool           `json:"checked" gorm:"default:0;not null"` // whether the Recipient has checked the message
}

type Model

type Model struct {
	ID        uint            `gorm:"primarykey" json:"id"`
	CreatedAt types.UnixTime  `json:"created_at"`
	UpdatedAt types.UnixTime  `json:"updated_at"`
	DeletedAt *gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
}

type Provider

type Provider struct {
	Model

	Address         string           `json:"address" gorm:"size:32;not null;uniqueIndex:uidx_provider_addr"`
	Status          bool             `json:"status"`         // true: reachable false: unreachable
	UptimeAverage   float64          `json:"uptime_average"` // reachable success rate
	IsoCode         string           `json:"iso_code" gorm:"size:4"`
	Region          string           `json:"region" gorm:"size:32"`
	RawPower        decimal.Decimal  `json:"raw_power" gorm:"type:decimal(50,0)"`
	QualityAdjPower decimal.Decimal  `json:"quality_adj_power" gorm:"type:decimal(50,0)"`
	FreeSpace       *decimal.Decimal `json:"free_space" gorm:"type:decimal(50,0)"`

	Price         *string          `json:"price" gorm:"size:80"`
	VerifiedPrice *string          `json:"verified_price" gorm:"size:80"`
	MinPieceSize  *decimal.Decimal `json:"min_piece_size" gorm:"type:decimal(50,0)"`
	MaxPieceSize  *decimal.Decimal `json:"max_piece_size" gorm:"type:decimal(50,0)"`

	Score                       decimal.Decimal `json:"score" gorm:"type:decimal(4,0)"`
	ScoreUptime                 decimal.Decimal `json:"score_uptime" gorm:"type:decimal(4,0)"`
	ScoreStorageDeals           decimal.Decimal `json:"score_storage_deals" gorm:"type:decimal(4,0)"`
	ScoreCommittedSectorsProofs decimal.Decimal `json:"score_committed_sectors_proofs" gorm:"type:decimal(4,0)"`

	DealTotal           uint64          `json:"deal_total"`
	DealNoPenalties     uint64          `json:"deal_no_penalties"`
	DealAveragePrice    decimal.Decimal `json:"deal_average_price" gorm:"type:decimal(50,0)"`
	DealDataStored      decimal.Decimal `json:"deal_data_stored" gorm:"type:decimal(50,0)"`
	DealSlashed         uint64          `json:"deal_slashed"`
	DealTerminated      uint64          `json:"deal_terminated"`
	DealFaultTerminated uint64          `json:"deal_fault_terminated"`
	DealSuccessRate     decimal.Decimal `json:"deal_success_rate" gorm:"type:decimal(16,12)"`

	FirstDealTime        int64           `json:"first_deal_time"`
	RetrievalSuccessRate decimal.Decimal `json:"retrieval_success_rate" gorm:"type:decimal(16,12)"`
	Owner                string          `json:"owner" gorm:"size:255;index"`
	ReviewScore          float64         `json:"review_score"`
	Reviews              uint64          `json:"reviews"`
}

type ProviderInfo

type ProviderInfo struct {
	Model

	Uid             uuid.UUID `json:"uid" gorm:"size:64;not null;index"`
	Address         string    `json:"address" gorm:"size:32;not null;uniqueIndex:uidx_pinfo_addr"`
	AvailableDeals  string    `json:"available_deals" gorm:"size:128"`
	Bandwidth       string    `json:"bandwidth" gorm:"size:128"`
	SealingSpeed    string    `json:"sealing_speed" gorm:"size:128"`
	ParallelDeals   string    `json:"parallel_deals" gorm:"size:128"`
	RenewableEnergy string    `json:"renewable_energy" gorm:"size:128"`
	Certification   string    `json:"certification" gorm:"size:128"`
	IsMember        string    `json:"is_member" gorm:"size:16"`
	Experience      string    `json:"experience" gorm:"size:128"`
}

type ProviderStatsMonthly

type ProviderStatsMonthly struct {
	ID       uint           `gorm:"primarykey" json:"id"`
	Month    types.UnixTime `json:"month" gorm:"uniqueIndex:idx_psm_sp_cli_m,priority:3"`
	Provider string         `json:"provider" gorm:"size:32;not null;uniqueIndex:idx_psm_sp_cli_m,priority:1"`
	Client   string         `json:"client" gorm:"size:32;not null;uniqueIndex:idx_psm_sp_cli_m,priority:2"`
}

type Review

type Review struct {
	Model

	Uid      uuid.UUID `json:"uid" gorm:"size:64"`
	Client   string    `json:"client" gorm:"size:32"` // address id
	Provider string    `json:"provider" gorm:"size:32"`
	Score    int       `json:"score"`
	Content  string    `json:"content" gorm:"size:1024"`
	Title    string    `json:"title" gorm:"size:128"`
}

type User

type User struct {
	Model
	Uid            uuid.UUID `json:"uid" gorm:"size:64;not null;uniqueIndex:uidx_user_uid"`
	Email          string    `json:"email" gorm:"size:255;not null;uniqueIndex:uidx_user_email"`
	HashedPassword string    `json:"password" gorm:"column:password;size:80"`
	Type           string    `json:"type" gorm:"size:32;not null;uniqueIndex:uidx_user_addr_type,priority:2"` // "sp_owner" or "data_client" or "system"
	AddressRobust  string    `json:"address_robust" gorm:"size:255;not null;uniqueIndex:uidx_user_addr_type,priority:1"`
	AddressId      string    `json:"address_id" gorm:"size:32"`
	Name           string    `json:"name" gorm:"size:128"`
	Avatar         string    `json:"avatar" gorm:"size:1024"`
	Location       string    `json:"location" gorm:"size:128"`
	ContactEmail   string    `json:"contact_email" gorm:"size:256"`
	Slack          string    `json:"slack" gorm:"size:128"`
	Github         string    `json:"github" gorm:"size:128"`
	Twitter        string    `json:"twitter" gorm:"size:128"`
	Description    string    `json:"description" gorm:"size:2048"`
}

type UserRelation

type UserRelation struct {
	Model

	Uid     uuid.UUID `json:"uid" gorm:"size:64;uniqueIndex:uidx_userrel_uid_ptuid,priority:1"`
	Partner uuid.UUID `json:"partner" gorm:"size:64;uniqueIndex:uidx_userrel_uid_ptuid,priority:2"`
}

type UserStatus

type UserStatus struct {
	Model

	Uid    uuid.UUID `json:"uid" gorm:"size:64;uniqueIndex"`
	Online bool      `json:"online"`
}

Jump to

Keyboard shortcuts

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