types

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncAccessControlMap = map[string]UserAccessControl{
	"CreateAsset":      UserAPIKeyCreateFile,
	"ListAssets":       UserAPIKeyReadFile,
	"DeleteAsset":      UserAPIKeyDeleteFile,
	"ShareAssets":      UserAPIKeyReadFile,
	"CreateAssetGroup": UserAPIKeyCreateFolder,
	"ListAssetGroup":   UserAPIKeyReadFolder,
	"DeleteAssetGroup": UserAPIKeyDeleteFolder,
	"RenameAssetGroup": UserAPIKeyCreateFolder,
}

key is function name, value is permission name

ReplicaStatusAll contains all possible replica statuses

Functions

This section is empty.

Types

type AWSDataInfo added in v0.1.13

type AWSDataInfo struct {
	Bucket         string    `db:"bucket"`
	Cid            string    `db:"cid"`
	Replicas       int       `db:"replicas"`
	IsDistribute   bool      `db:"is_distribute"`
	DistributeTime time.Time `db:"distribute_time"`
	Size           float64   `db:"size"`
}

AWSDataInfo aws data

type ActivationDetail added in v0.1.10

type ActivationDetail struct {
	NodeID        string   `json:"node_id" db:"node_id"`
	AreaID        string   `json:"area_id" `
	ActivationKey string   `json:"activation_key" db:"activation_key"`
	NodeType      NodeType `json:"node_type" db:"node_type"`
	IP            string   `json:"ip" db:"ip"`
}

func (*ActivationDetail) Marshal added in v0.1.10

func (d *ActivationDetail) Marshal() (string, error)

func (*ActivationDetail) Unmarshal added in v0.1.10

func (d *ActivationDetail) Unmarshal(code string) error

type AssetGroup added in v0.1.11

type AssetGroup struct {
	ID          int       `db:"id"`
	UserID      string    `db:"user_id"`
	Name        string    `db:"name"`
	Parent      int       `db:"parent"`
	AssetCount  int       `db:"asset_count"`
	AssetSize   int64     `db:"asset_size"`
	CreatedTime time.Time `db:"created_time"`
}

AssetGroup user asset group

type AssetHash

type AssetHash string

AssetHash is an identifier for a asset.

func (AssetHash) String

func (c AssetHash) String() string

type AssetOverview added in v0.1.11

type AssetOverview struct {
	AssetRecord      *AssetRecord
	UserAssetDetail  *UserAssetDetail
	VisitCount       int
	RemainVisitCount int
}

type AssetProperty added in v0.1.10

type AssetProperty struct {
	AssetCID  string
	AssetName string
	AssetSize int64
	AssetType string
	NodeID    string
	Password  string
	GroupID   int
}

type AssetPullProgress

type AssetPullProgress struct {
	CID             string
	Status          ReplicaStatus
	Msg             string
	BlocksCount     int
	DoneBlocksCount int
	Size            int64
	DoneSize        int64
}

AssetPullProgress represents the progress of pulling an asset

type AssetRecord

type AssetRecord struct {
	CID                   string          `db:"cid"`
	Hash                  string          `db:"hash"`
	NeedEdgeReplica       int64           `db:"edge_replicas"`
	TotalSize             int64           `db:"total_size"`
	TotalBlocks           int64           `db:"total_blocks"`
	Expiration            time.Time       `db:"expiration"`
	CreatedTime           time.Time       `db:"created_time"`
	EndTime               time.Time       `db:"end_time"`
	NeedCandidateReplicas int64           `db:"candidate_replicas"`
	ServerID              dtypes.ServerID `db:"scheduler_sid"`
	State                 string          `db:"state"`
	NeedBandwidth         int64           `db:"bandwidth"` // unit:MiB/
	Note                  string          `db:"note"`

	RetryCount        int64 `db:"retry_count"`
	ReplenishReplicas int64 `db:"replenish_replicas"`
	ReplicaInfos      []*ReplicaInfo

	SPCount int64
}

AssetRecord represents information about an asset record

type AssetStateInfo

type AssetStateInfo struct {
	State             string `db:"state"`
	RetryCount        int64  `db:"retry_count"`
	Hash              string `db:"hash"`
	ReplenishReplicas int64  `db:"replenish_replicas"`
}

AssetStateInfo represents information about an asset state

type AssetStatistics

type AssetStatistics struct {
	ReplicaCount      int
	UserDownloadCount int
}

AssetStatistics Statistics on asset pulls and downloads

type AssetStats

type AssetStats struct {
	TotalAssetCount     int
	TotalBlockCount     int
	WaitCacheAssetCount int
	InProgressAssetCID  string
	DiskUsage           float64
}

AssetStats contains statistics about assets

type AssetStatus added in v0.1.11

type AssetStatus struct {
	IsExist           bool
	IsExpiration      bool
	IsVisitOutOfLimit bool
}

type AssetType added in v0.1.10

type AssetType int

AssetType represents the type of a asset

const (
	// AssetTypeCarfile type
	AssetTypeCarfile AssetType = iota
	// AssetTypeFile type
	AssetTypeFile
)

type AssetView added in v0.1.14

type AssetView struct {
	TopHash string
	// key bucketID, value bucketHash
	BucketHashes map[uint32]string
}

type AuthUserUploadDownloadAsset added in v0.1.11

type AuthUserUploadDownloadAsset struct {
	UserID     string
	AssetCID   string
	AssetSize  int64
	Expiration time.Time
}

type CandidateDownloadInfo

type CandidateDownloadInfo struct {
	NodeID  string
	Address string
	Tk      *Token
	// download from aws
	AWSBucket string
	// download from aws
	AWSKey string
}

CandidateDownloadInfo represents download information for a candidate

type ConnectOptions

type ConnectOptions struct {
	Token         string
	TcpServerPort int
	// private minio storage only, not public storage
	IsPrivateMinioOnly bool
	ExternalURL        string
}

type CreateAssetReq added in v0.1.10

type CreateAssetReq struct {
	UserID string
	AssetProperty
}

type CreateAssetRsp added in v0.1.10

type CreateAssetRsp struct {
	UploadURL     string
	Token         string
	AlreadyExists bool
}

type DownloadHistory

type DownloadHistory struct {
	ID           string    `json:"-"`
	NodeID       string    `json:"node_id" db:"node_id"`
	BlockCID     string    `json:"block_cid" db:"block_cid"`
	AssetCID     string    `json:"asset_cid" db:"asset_cid"`
	BlockSize    int       `json:"block_size" db:"block_size"`
	Speed        int64     `json:"speed" db:"speed"`
	Reward       int64     `json:"reward" db:"reward"`
	Status       int       `json:"status" db:"status"`
	FailedReason string    `json:"failed_reason" db:"failed_reason"`
	ClientIP     string    `json:"client_ip" db:"client_ip"`
	CreatedTime  time.Time `json:"created_time" db:"created_time"`
	CompleteTime time.Time `json:"complete_time" db:"complete_time"`
}

DownloadHistory represents the record of a node download

type EdgeDownloadInfo

type EdgeDownloadInfo struct {
	Address string
	Tk      *Token
	NodeID  string
	NatType string
}

EdgeDownloadInfo represents download information for an edge node

type EdgeDownloadInfoList

type EdgeDownloadInfoList struct {
	Infos        []*EdgeDownloadInfo
	SchedulerURL string
	SchedulerKey string
}

EdgeDownloadInfoList represents a list of EdgeDownloadInfo structures along with scheduler URL and key

type EventTopics

type EventTopics string

EventTopics represents topics for pub/sub events

const (
	// EventNodeOnline node online event
	EventNodeOnline EventTopics = "node_online"
	// EventNodeOffline node offline event
	EventNodeOffline EventTopics = "node_offline"
)

func (EventTopics) String

func (t EventTopics) String() string

type GeneratedCarInfo added in v0.1.10

type GeneratedCarInfo struct {
	DataCid   string
	PieceCid  string
	PieceSize uint64
	Path      string
}

type InProgressAsset

type InProgressAsset struct {
	CID       string
	TotalSize int64
	DoneSize  int64
}

InProgressAsset represents an asset that is currently being fetched, including its progress details.

type JWTPayload added in v0.1.10

type JWTPayload struct {
	// role base access controller permission
	Allow []auth.Permission
	ID    string
	// TODO remove NodeID later, any role id replace as ID
	NodeID string
	// Extend is json string
	Extend string
	// The sub permission of user
	AccessControlList []UserAccessControl
}

type ListAssetGroupRsp added in v0.1.11

type ListAssetGroupRsp struct {
	Total       int           `json:"total"`
	AssetGroups []*AssetGroup `json:"infos"`
}

ListAssetGroupRsp list asset group records

type ListAssetRecordRsp added in v0.1.11

type ListAssetRecordRsp struct {
	Total          int              `json:"total"`
	AssetOverviews []*AssetOverview `json:"asset_infos"`
}

ListAssetRecordRsp list asset records

type ListAssetSummaryRsp added in v0.1.11

type ListAssetSummaryRsp struct {
	Total int                 `json:"total"`
	List  []*UserAssetSummary `json:"list"`
}

ListAssetSummaryRsp list asset and group

type ListDownloadRecordRsp

type ListDownloadRecordRsp struct {
	Data  []DownloadHistory `json:"data"`
	Total int64             `json:"total"`
}

ListDownloadRecordRsp download record rsp

type ListNodeAssetRsp added in v0.1.10

type ListNodeAssetRsp struct {
	Total          int              `json:"total"`
	NodeAssetInfos []*NodeAssetInfo `json:"asset_infos"`
}

ListNodeAssetRsp list node assets

type ListNodeReplicaRsp added in v0.1.16

type ListNodeReplicaRsp struct {
	Total            int                `json:"total"`
	NodeReplicaInfos []*NodeReplicaInfo `json:"infos"`
}

ListNodeReplicaRsp list node assets

type ListNodesRsp

type ListNodesRsp struct {
	Data  []NodeInfo `json:"data"`
	Total int64      `json:"total"`
}

ListNodesRsp list node rsp

type ListReplicaEventRsp added in v0.1.10

type ListReplicaEventRsp struct {
	Total         int                 `json:"total"`
	ReplicaEvents []*ReplicaEventInfo `json:"replica_events"`
}

ListReplicaEventRsp list replica events

type ListReplicaRsp added in v0.1.11

type ListReplicaRsp struct {
	Total        int            `json:"total"`
	ReplicaInfos []*ReplicaInfo `json:"replica_infos"`
}

ListReplicaRsp list asset replicas

type ListRetrieveEventRsp added in v0.1.11

type ListRetrieveEventRsp struct {
	Total              int              `json:"total"`
	RetrieveEventInfos []*RetrieveEvent `json:"retrieve_event_infos"`
}

ListRetrieveEventRsp list retrieve event

type ListStorageStatsRsp added in v0.1.11

type ListStorageStatsRsp struct {
	Total    int             `json:"total"`
	Storages []*StorageStats `json:"infos"`
}

ListStorageStatsRsp list storage stats records

type ListValidationResultRsp

type ListValidationResultRsp struct {
	Total                 int                    `json:"total"`
	ValidationResultInfos []ValidationResultInfo `json:"validation_result_infos"`
}

ListValidationResultRsp list validated result

type ListWorkloadRecordRsp added in v0.1.10

type ListWorkloadRecordRsp struct {
	Total               int               `json:"total"`
	WorkloadRecordInfos []*WorkloadRecord `json:"workload_result_infos"`
}

ListWorkloadRecordRsp list workload result

type MinioConfig added in v0.1.11

type MinioConfig struct {
	Endpoint        string
	AccessKeyID     string
	SecretAccessKey string
}

type MinioUploadFileEvent added in v0.1.11

type MinioUploadFileEvent struct {
	AssetCID   string
	Size       int64
	CreateTime time.Time
	Expiration time.Time
}

type NatPunchReq

type NatPunchReq struct {
	Tk      *Token
	NodeID  string
	Timeout time.Duration
}

type NatType

type NatType int

NatType represents the type of NAT of a node

const (
	// NatTypeUnknown Unknown NAT type
	NatTypeUnknown NatType = iota
	// NatTypeNo not  nat
	NatTypeNo
	// NatTypeSymmetric Symmetric NAT
	NatTypeSymmetric
	// NatTypeFullCone Full cone NAT
	NatTypeFullCone
	// NatTypeRestricted Restricted NAT
	NatTypeRestricted
	// NatTypePortRestricted Port-restricted NAT
	NatTypePortRestricted
)

func (NatType) FromString

func (n NatType) FromString(natType string) NatType

func (NatType) String

func (n NatType) String() string

type NodeActivation added in v0.1.10

type NodeActivation struct {
	NodeID         string
	ActivationCode string
}

type NodeAssetInfo added in v0.1.10

type NodeAssetInfo struct {
	Hash       string    `db:"hash"`
	Cid        string    `db:"cid"`
	TotalSize  int64     `db:"total_size"`
	Expiration time.Time `db:"expiration"`
	EndTime    time.Time `db:"end_time"`
}

NodeAssetInfo node asset info of web

type NodeDynamicInfo added in v0.1.10

type NodeDynamicInfo struct {
	NodeID          string  `json:"node_id" form:"nodeId" gorm:"column:node_id;comment:;" db:"node_id"`
	DiskUsage       float64 `json:"disk_usage" form:"diskUsage" gorm:"column:disk_usage;comment:;" db:"disk_usage"`
	CPUUsage        float64
	MemoryUsage     float64
	Status          NodeStatus
	TitanDiskUsage  float64   `db:"titan_disk_usage"`
	IncomeIncr      float64   // Base points increase every half hour (30 minute)
	OnlineDuration  int       `db:"online_duration"` // unit:Minute
	Profit          float64   `db:"profit"`
	LastSeen        time.Time `db:"last_seen"`
	DownloadTraffic int64     `db:"download_traffic"`
	UploadTraffic   int64     `db:"upload_traffic"`
	AssetCount      int64     `db:"asset_count"`
	RetrieveCount   int64     `db:"retrieve_count"`
}

NodeDynamicInfo Dynamic information about the node

type NodeIPInfo added in v0.1.11

type NodeIPInfo struct {
	NodeID      string
	IP          string
	ExternalURL string
}

NodeIPInfo

type NodeInfo

type NodeInfo struct {
	Type       NodeType
	ExternalIP string
	InternalIP string

	FirstTime          time.Time       `db:"first_login_time"`
	BandwidthUp        int64           `json:"bandwidth_up" db:"bandwidth_up"`
	BandwidthDown      int64           `json:"bandwidth_down" db:"bandwidth_down"`
	DiskSpace          float64         `json:"disk_space" form:"diskSpace" gorm:"column:disk_space;comment:;" db:"disk_space"`
	AvailableDiskSpace float64         `json:"available_disk_space" form:"availableDiskSpace" gorm:"column:available_disk_space;comment:;" db:"available_disk_space"`
	SystemVersion      string          `json:"system_version" form:"systemVersion" gorm:"column:system_version;comment:;" db:"system_version"`
	DiskType           string          `json:"disk_type" form:"diskType" gorm:"column:disk_type;comment:;" db:"disk_type"`
	IoSystem           string          `json:"io_system" form:"ioSystem" gorm:"column:io_system;comment:;" db:"io_system"`
	NodeName           string          `json:"node_name" form:"nodeName" gorm:"column:node_name;comment:;" db:"node_name"`
	Memory             float64         `json:"memory" form:"memory" gorm:"column:memory;comment:;" db:"memory"`
	CPUCores           int             `json:"cpu_cores" form:"cpuCores" gorm:"column:cpu_cores;comment:;" db:"cpu_cores"`
	MacLocation        string          `json:"mac_location" form:"macLocation" gorm:"column:mac_location;comment:;" db:"mac_location"`
	NATType            string          `db:"nat_type"`
	PortMapping        string          `db:"port_mapping"`
	SchedulerID        dtypes.ServerID `db:"scheduler_sid"`
	DeactivateTime     int64           `db:"deactivate_time"`
	CPUInfo            string          `json:"cpu_info" form:"cpuInfo" gorm:"column:cpu_info;comment:;" db:"cpu_info"`

	NodeDynamicInfo
}

NodeInfo contains information about a node.

type NodeReplicaInfo added in v0.1.16

type NodeReplicaInfo struct {
	Hash      string        `db:"hash"`
	Cid       string        `db:"cid"`
	TotalSize int64         `db:"total_size"`
	Status    ReplicaStatus `db:"status"`
	DoneSize  int64         `db:"done_size"`
	StartTime time.Time     `db:"start_time"`
	EndTime   time.Time     `db:"end_time"`
}

NodeReplicaInfo node replica info of web

type NodeReplicaRsp

type NodeReplicaRsp struct {
	Replica    []*NodeReplicaStatus
	TotalCount int
}

NodeReplicaRsp represents the replicas of a node asset

type NodeReplicaStatus

type NodeReplicaStatus struct {
	Hash   string        `db:"hash"`
	Status ReplicaStatus `db:"status"`
}

NodeReplicaStatus represents the status of a node cache

type NodeSnapshot added in v0.1.11

type NodeSnapshot struct {
	NodeID             string    `db:"node_id"`
	OnlineDuration     int       `db:"online_duration"` // unit:Minute
	DiskUsage          float64   `db:"disk_usage"`
	LastSeen           time.Time `db:"last_seen"`
	BandwidthUp        int64     `db:"bandwidth_up"`
	BandwidthDown      int64     `db:"bandwidth_down"`
	Profit             float64   `db:"profit"`
	AvailableDiskSpace float64   `db:"available_disk_space"`
	TitanDiskUsage     float64   `db:"titan_disk_usage"`
}

NodeSnapshot contains the real-time status information of a node, such as the last online time, online duration, CPU usage rate, and score changes.

type NodeStatus added in v0.1.10

type NodeStatus int

NodeStatus node status

const (
	NodeOffline NodeStatus = iota

	NodeServicing

	NodeUnregister
	// Exceptions
	NodeNatSymmetric
)

func (NodeStatus) String added in v0.1.10

func (n NodeStatus) String() string

type NodeType

type NodeType int

NodeType node type

const (
	NodeUnknown NodeType = iota

	NodeEdge
	NodeCandidate
	NodeValidator
	NodeScheduler
	NodeLocator
	NodeUpdater
)
var RunningNodeType NodeType

RunningNodeType represents the type of the running node.

func (NodeType) String

func (n NodeType) String() string

type NodeWorkloadReport

type NodeWorkloadReport struct {
	// CipherText encrypted []*WorkloadReport by scheduler public key
	CipherText []byte
	// Sign signs CipherText by node private key
	Sign []byte
}

type OpenRPCDocument

type OpenRPCDocument map[string]interface{}

type PullAssetReq

type PullAssetReq struct {
	CID        string
	Replicas   int64
	Expiration time.Time

	Bucket    string
	Hash      string
	Bandwidth int64 // unit:MiB/s

	SeedNodeID        string
	CandidateReplicas int64

	CandidateNodeList []string
	EdgeNodeList      []string
}

PullAssetReq represents a request to pull an asset to Titan

type PullResult

type PullResult struct {
	Progresses       []*AssetPullProgress
	DiskUsage        float64
	TotalBlocksCount int
	AssetCount       int
}

PullResult contains information about the result of a data pull

type RemoveAssetResult

type RemoveAssetResult struct {
	BlocksCount int
	DiskUsage   float64
}

RemoveAssetResult contains information about the result of removing an asset

type ReplicaEvent added in v0.1.10

type ReplicaEvent int
const (
	// ReplicaEventRemove event
	ReplicaEventRemove ReplicaEvent = iota
	// ReplicaEventAdd event
	ReplicaEventAdd
	// MinioEventAdd event
	MinioEventAdd
)

type ReplicaEventInfo added in v0.1.10

type ReplicaEventInfo struct {
	NodeID  string       `db:"node_id"`
	Event   ReplicaEvent `db:"event"`
	Hash    string       `db:"hash"`
	EndTime time.Time    `db:"end_time"`

	Cid        string    `db:"cid"`
	TotalSize  int64     `db:"total_size"`
	Expiration time.Time `db:"expiration"`
}

ReplicaEventInfo replica event info

type ReplicaInfo

type ReplicaInfo struct {
	Hash        string        `db:"hash"`
	NodeID      string        `db:"node_id"`
	Status      ReplicaStatus `db:"status"`
	IsCandidate bool          `db:"is_candidate"`
	EndTime     time.Time     `db:"end_time"`
	DoneSize    int64         `db:"done_size"`
	StartTime   time.Time     `db:"start_time"`
}

ReplicaInfo represents information about an asset replica

type ReplicaStatus

type ReplicaStatus int

ReplicaStatus represents the status of a replica pull

const (
	// ReplicaStatusWaiting status
	ReplicaStatusWaiting ReplicaStatus = iota
	// ReplicaStatusPulling status
	ReplicaStatusPulling
	// ReplicaStatusFailed status
	ReplicaStatusFailed
	// ReplicaStatusSucceeded status
	ReplicaStatusSucceeded
)

func (ReplicaStatus) String

func (c ReplicaStatus) String() string

String status to string

type RetrieveEvent added in v0.1.11

type RetrieveEvent struct {
	TokenID     string  `db:"token_id"`
	NodeID      string  `db:"node_id"`
	ClientID    string  `db:"client_id"`
	CID         string  `db:"cid"`
	Size        int64   `db:"size"`
	CreatedTime int64   `db:"created_time"`
	EndTime     int64   `db:"end_time"`
	Profit      float64 `db:"profit"`
}

RetrieveEvent retrieve event

type SchedulerCfg

type SchedulerCfg struct {
	SchedulerURL string `db:"scheduler_url"`
	AreaID       string `db:"area_id"`
	Weight       int    `db:"weight"`
	AccessToken  string `db:"access_token"`
}

SchedulerCfg scheduler config

type StorageStats added in v0.1.11

type StorageStats struct {
	TotalSize    int64 `db:"total_storage_size"`
	UsedSize     int64 `db:"used_storage_size"`
	TotalTraffic int64 `db:"total_traffic"`
	EnableVIP    bool  `db:"enable_vip"`
	AssetCount   int   `db:"asset_count"`
}

StorageStats storage stats of user

type Token

type Token struct {
	ID string
	// CipherText encrypted TokenPayload by public key
	CipherText string
	// Sign signs CipherText by scheduler private key
	Sign string
}

Token access download asset

type TokenPayload

type TokenPayload struct {
	ID          string    `db:"token_id"`
	NodeID      string    `db:"node_id"`
	AssetCID    string    `db:"asset_id"`
	ClientID    string    `db:"client_id"`
	LimitRate   int64     `db:"limit_rate"`
	CreatedTime time.Time `db:"created_time"`
	Expiration  time.Time `db:"expiration"`
}

TokenPayload payload of token

type UploadProgress added in v0.1.10

type UploadProgress struct {
	TotalSize int64
	DoneSize  int64
}

type UploadingAsset added in v0.1.10

type UploadingAsset struct {
	UserID          string
	TokenExpiration time.Time
	Progress        *UploadProgress
}

type UserAPIKeysInfo added in v0.1.11

type UserAPIKeysInfo struct {
	CreatedTime time.Time
	APIKey      string
}

type UserAccessControl added in v0.1.11

type UserAccessControl string
const (
	UserAPIKeyReadFile     UserAccessControl = "readFile"
	UserAPIKeyCreateFile   UserAccessControl = "createFile"
	UserAPIKeyDeleteFile   UserAccessControl = "deleteFile"
	UserAPIKeyReadFolder   UserAccessControl = "readFolder"
	UserAPIKeyCreateFolder UserAccessControl = "createFolder"
	UserAPIKeyDeleteFolder UserAccessControl = "deleteFolder"
)

type UserAssetDetail added in v0.1.11

type UserAssetDetail struct {
	UserID      string    `db:"user_id"`
	Hash        string    `db:"hash"`
	AssetName   string    `db:"asset_name"`
	AssetType   string    `db:"asset_type"`
	ShareStatus int64     `db:"share_status"`
	Expiration  time.Time `db:"expiration"`
	CreatedTime time.Time `db:"created_time"`
	TotalSize   int64     `db:"total_size"`
	Password    string    `db:"password"`
	GroupID     int       `db:"group_id"`
}

type UserAssetShareStatus added in v0.1.11

type UserAssetShareStatus int
const (
	UserAssetShareStatusUnshare UserAssetShareStatus = iota
	UserAssetShareStatusShared
	UserAssetShareStatusForbid
)

type UserAssetSummary added in v0.1.11

type UserAssetSummary struct {
	AssetOverview *AssetOverview
	AssetGroup    *AssetGroup
}

UserAssetSummary user asset and group

type UserInfo added in v0.1.11

type UserInfo struct {
	TotalSize     int64 `db:"total_storage_size"`
	UsedSize      int64 `db:"used_storage_size"`
	TotalTraffic  int64 `db:"total_traffic"`
	PeakBandwidth int64 `db:"peak_bandwidth"`
	DownloadCount int64 `db:"download_count"`
	EnableVIP     bool  `db:"enable_vip"`

	UpdateTime time.Time `db:"update_peak_time"`
}

type ValidationInfo

type ValidationInfo struct {
	NextElectionTime time.Time
}

ValidationInfo Validation, election related information

type ValidationResultInfo

type ValidationResultInfo struct {
	ID               int              `db:"id"`
	RoundID          string           `db:"round_id"`
	NodeID           string           `db:"node_id"`
	Cid              string           `db:"cid"`
	ValidatorID      string           `db:"validator_id"`
	BlockNumber      int64            `db:"block_number"` // number of blocks verified
	Status           ValidationStatus `db:"status"`
	Duration         int64            `db:"duration"` // validator duration, microsecond
	Bandwidth        float64          `db:"bandwidth"`
	StartTime        time.Time        `db:"start_time"`
	EndTime          time.Time        `db:"end_time"`
	Profit           float64          `db:"profit"`
	CalculatedProfit bool             `db:"calculated_profit"`
	TokenID          string           `db:"token_id"`
	FileSaved        bool             `db:"file_saved"`
	NodeCount        int              `db:"node_count"`
}

ValidationResultInfo validator result info

type ValidationStatus

type ValidationStatus int

ValidationStatus Validation Status

const (
	// ValidationStatusCreate  is the initial validation status when the validation process starts.
	ValidationStatusCreate ValidationStatus = iota
	// ValidationStatusSuccess is the validation status when the validation is success.
	ValidationStatusSuccess
	// ValidationStatusCancel is the validation status when the validation is canceled.
	ValidationStatusCancel

	// ValidationStatusNodeTimeOut is the validation status when the node times out.
	ValidationStatusNodeTimeOut
	// ValidationStatusValidateFail is the validation status when the validation fail.
	ValidationStatusValidateFail

	// ValidationStatusValidatorTimeOut is the validation status when the validator times out.
	ValidationStatusValidatorTimeOut
	// ValidationStatusGetValidatorBlockErr is the validation status when there is an error getting the blocks from validator.
	ValidationStatusGetValidatorBlockErr
	// ValidationStatusValidatorMismatch is the validation status when the validator mismatches.
	ValidationStatusValidatorMismatch

	// ValidationStatusLoadDBErr is the validation status when there is an error loading the database.
	ValidationStatusLoadDBErr
	// ValidationStatusCIDToHashErr is the validation status when there is an error converting a CID to a hash.
	ValidationStatusCIDToHashErr

	// ValidationStatusNodeOffline is the validation status when the node offline.
	ValidationStatusNodeOffline
)

type Workload

type Workload struct {
	DownloadSpeed int64
	DownloadSize  int64
	StartTime     time.Time
	EndTime       time.Time
	BlockCount    int64
}

type WorkloadRecord added in v0.1.10

type WorkloadRecord struct {
	TokenPayload
	Status         WorkloadStatus `db:"status"`
	ClientEndTime  int64          `db:"client_end_time"`
	ClientWorkload []byte         `db:"client_workload"`
	NodeWorkload   []byte         `db:"node_workload"`
}

WorkloadReportRecord use to store workloadReport

type WorkloadReport

type WorkloadReport struct {
	TokenID  string
	ClientID string
	NodeID   string
	Workload *Workload
}

type WorkloadStatus added in v0.1.10

type WorkloadStatus int

WorkloadStatus Workload Status

const (
	// WorkloadStatusCreate is the initial workload status when the workload process starts.
	WorkloadStatusCreate WorkloadStatus = iota
	// WorkloadStatusSucceeded is the workload status when the workload is succeeded.
	WorkloadStatusSucceeded
	// WorkloadStatusFailed is the workload status when the workload is failed.
	WorkloadStatusFailed
	// WorkloadStatusInvalid is the workload status when the workload is invalid.
	WorkloadStatusInvalid
)

Jump to

Keyboard shortcuts

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