types

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

ReplicaStatusAll contains all possible replica statuses

Functions

This section is empty.

Types

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"`
}

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 AssetHash

type AssetHash string

AssetHash is an identifier for a asset.

func (AssetHash) String

func (c AssetHash) String() string

type AssetProperty added in v0.1.10

type AssetProperty struct {
	CID    string
	Name   string
	Status int
	Size   int64
}

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/s

	AssetName string `db:"asset_name"`

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

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 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 AuthUserDownloadAsset added in v0.1.10

type AuthUserDownloadAsset struct {
	UserID   string
	AssetCID string
}

type AuthUserUploadAsset added in v0.1.10

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

type CandidateDownloadInfo

type CandidateDownloadInfo struct {
	NodeID  string
	Address string
	Tk      *Token
}

CandidateDownloadInfo represents download information for a candidate

type ConnectOptions

type ConnectOptions struct {
	Token         string
	TcpServerPort int
}

type CreateAssetReq added in v0.1.10

type CreateAssetReq struct {
	UserID    string
	AssetCID  string
	AssetName string
	AssetSize int64
}

type CreateAssetRsp added in v0.1.10

type CreateAssetRsp struct {
	CandidateAddr string
	Token         string
}

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 {
	Allow []auth.Permission
	ID    string
	//TODO remove NodeID later, any role id replace as ID
	NodeID string
	// Extend is json string
	Extend string
}

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 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 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 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
	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 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"`
	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"`

	NodeDynamicInfo
}

NodeInfo contains information about a node.

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 NodeStatus added in v0.1.10

type NodeStatus int

NodeStatus node status

const (
	NodeOffine 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 {
	ID         string
	CID        string
	Hash       string
	Replicas   int64
	Expiration time.Time
	Bandwidth  int64 // unit:MiB/s
}

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
)

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"`
}

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 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 StorageSize added in v0.1.10

type StorageSize struct {
	TotalSize int64 `db:"total_storage_size"`
	UsedSize  int64 `db:"used_storage_size"`
}

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 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"`
}

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
)

type Workload

type Workload struct {
	DownloadSpeed int64
	DownloadSize  int64
	StartTime     int64
	EndTime       int64
	BlockCount    int64
}

type WorkloadRecord added in v0.1.10

type WorkloadRecord struct {
	TokenPayload
	Status         WorkloadStatus `db:"status"`
	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