Documentation ¶
Index ¶
- Variables
- type AssetEvent
- type AssetEventInfo
- type AssetHash
- type AssetPullProgress
- type AssetRecord
- type AssetStateInfo
- type AssetStatistics
- type AssetStats
- type Base
- type CandidateDownloadInfo
- type ConnectOptions
- type DownloadHistory
- type EdgeDownloadInfo
- type EdgeDownloadInfoList
- type EventTopics
- type InProgressAsset
- type ListDownloadRecordRsp
- type ListNodesRsp
- type ListReplicaInfosReq
- type ListReplicaInfosRsp
- type ListValidationResultRsp
- type NatPunchReq
- type NatType
- type NodeInfo
- type NodeReplicaRsp
- type NodeReplicaStatus
- type NodeType
- type NodeWorkloadReport
- type OpenRPCDocument
- type PullAssetReq
- type PullResult
- type RemoveAssetResult
- type ReplicaInfo
- type ReplicaStatus
- type SchedulerCfg
- type Token
- type TokenPayload
- type ValidationInfo
- type ValidationResultInfo
- type ValidationStatus
- type Workload
- type WorkloadReport
Constants ¶
This section is empty.
Variables ¶
var ReplicaStatusAll = []ReplicaStatus{ ReplicaStatusWaiting, ReplicaStatusPulling, ReplicaStatusFailed, ReplicaStatusSucceeded, }
ReplicaStatusAll contains all possible replica statuses
Functions ¶
This section is empty.
Types ¶
type AssetEvent ¶
type AssetEvent string
AssetEvent Events for asset manipulation
const ( // AssetEventAdd status AssetEventAdd AssetEvent = "Add" // AssetEventRemove status AssetEventRemove AssetEvent = "Remove" )
type AssetEventInfo ¶
type AssetEventInfo struct { ID int Hash string `db:"hash"` Event AssetEvent `db:"event"` CreatedTime time.Time `db:"created_time"` Requester string `db:"requester"` Details string `db:"details"` }
AssetEventInfo Event info for asset manipulation
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"` CreateTime 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"` 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 ¶
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 CandidateDownloadInfo ¶
CandidateDownloadInfo represents download information for a candidate
type ConnectOptions ¶
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 ¶
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 InProgressAsset ¶
InProgressAsset represents an asset that is currently being fetched, including its progress details.
type ListDownloadRecordRsp ¶
type ListDownloadRecordRsp struct { Data []DownloadHistory `json:"data"` Total int64 `json:"total"` }
ListDownloadRecordRsp download record rsp
type ListNodesRsp ¶
ListNodesRsp list node rsp
type ListReplicaInfosReq ¶
type ListReplicaInfosReq struct { // Unix timestamp StartTime int64 `json:"start_time"` // Unix timestamp EndTime int64 `json:"end_time"` Cursor int `json:"cursor"` Count int `json:"count"` }
ListReplicaInfosReq represents a request to list asset replicas
type ListReplicaInfosRsp ¶
type ListReplicaInfosRsp struct { Replicas []*ReplicaInfo `json:"data"` Total int64 `json:"total"` }
ListReplicaInfosRsp represents a response containing a list of asset replicas
type ListValidationResultRsp ¶
type ListValidationResultRsp struct { Total int `json:"total"` ValidationResultInfos []ValidationResultInfo `json:"validation_result_infos"` }
ListValidationResultRsp list validated result
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 ¶
type NodeInfo ¶
type NodeInfo struct { Base NodeID string `json:"node_id" form:"nodeId" gorm:"column:node_id;comment:;" db:"node_id"` SerialNumber string `json:"serial_number" form:"serialNumber" gorm:"column:serial_number;comment:;"` Type NodeType `json:"type"` ExternalIP string `json:"external_ip" form:"externalIp" gorm:"column:external_ip;comment:;"` InternalIP string `json:"internal_ip" form:"internalIp" gorm:"column:internal_ip;comment:;"` IPLocation string `json:"ip_location" form:"ipLocation" gorm:"column:ip_location;comment:;"` PkgLossRatio float64 `json:"pkg_loss_ratio" form:"pkgLossRatio" gorm:"column:pkg_loss_ratio;comment:;"` Latency float64 `json:"latency" form:"latency" gorm:"column:latency;comment:;"` CPUUsage float64 `json:"cpu_usage" form:"cpuUsage" gorm:"column:cpu_usage;comment:;"` MemoryUsage float64 `json:"memory_usage" form:"memoryUsage" gorm:"column:memory_usage;comment:;"` IsOnline bool `json:"is_online" form:"isOnline" gorm:"column:is_online;comment:;"` DiskUsage float64 `json:"disk_usage" form:"diskUsage" gorm:"column:disk_usage;comment:;" db:"disk_usage"` Blocks int `json:"blocks" form:"blockCount" gorm:"column:blocks;comment:;" db:"blocks"` BandwidthUp float64 `json:"bandwidth_up" db:"bandwidth_up"` BandwidthDown float64 `json:"bandwidth_down" db:"bandwidth_down"` NATType string `json:"nat_type" form:"natType" gorm:"column:nat_type;comment:;" db:"nat_type"` 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"` Latitude float64 `json:"latitude" db:"latitude"` Longitude float64 `json:"longitude" db:"longitude"` 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"` ProductType string `json:"product_type" form:"productType" gorm:"column:product_type;comment:;" db:"product_type"` MacLocation string `json:"mac_location" form:"macLocation" gorm:"column:mac_location;comment:;" db:"mac_location"` OnlineDuration int `json:"online_duration" form:"onlineDuration" db:"online_duration"` Profit float64 `json:"profit" db:"profit"` DownloadTraffic float64 `json:"download_traffic" db:"download_traffic"` UploadTraffic float64 `json:"upload_traffic" db:"upload_traffic"` DownloadBlocks int `json:"download_blocks" form:"downloadCount" gorm:"column:download_blocks;comment:;" db:"download_blocks"` PortMapping string `db:"port_mapping"` LastSeen time.Time `db:"last_seen"` SchedulerID dtypes.ServerID `db:"scheduler_sid"` }
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 NodeType ¶
type NodeType int
NodeType node type
var RunningNodeType NodeType
RunningNodeType represents the type of the running node.
type NodeWorkloadReport ¶
type OpenRPCDocument ¶
type OpenRPCDocument map[string]interface{}
type PullAssetReq ¶
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 ¶
RemoveAssetResult contains information about the result of removing an asset
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 )
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 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"` CreateTime time.Time `db:"create_time"` Expiration time.Time `db:"expiration"` }
TokenPayload payload of token
type ValidationInfo ¶
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"` Processed bool `db:"processed"` UploadTraffic float64 `db:"upload_traffic"` }
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 successful. 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 fails. 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 )