models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NOT_ASSIGNED = iota
	IN_PROGRESS
	COMPLETED
	TERMINATED
)
View Source
const (
	FIL_C2_CPU512 = 1
	FIL_C2_CPU32G = 2
	FIL_C2_GPU512 = 3
	FIL_C2_GPU32G = 4
	Mining        = 5
)
View Source
const (
	TASK_REJECTED_STATUS = iota
	TASK_RECEIVED_STATUS
	TASK_RUNNING_STATUS
	TASK_SUBMITTED_STATUS
	TASK_FAILED_STATUS
	TASK_VERIFIED_STATUS
	TASK_INVALID_STATUS
	TASK_VERIFYFAILED_STATUS
	TASK_REWARDED_STATUS
	TASK_TIMEOUT_STATUS
	TASK_REPEATED_STATUS
	TASK_NSC_STATUS
	TASK_UNKNOWN_STATUS
)
View Source
const (
	RESOURCE_TYPE_CPU = 0
	RESOURCE_TYPE_GPU = 1
)
View Source
const (
	All_FLAG         = -1
	UN_DELETEED_FLAG = 0
	DELETED_FLAG     = 1
)
View Source
const (
	POD_UNKNOWN_STATUS = 0
	POD_RUNNING_STATUS = 1
	POD_DELETE_STATUS  = 2
)
View Source
const (
	JOB_REJECTED_STATUS   = -1
	JOB_RECEIVED_STATUS   = 0
	JOB_DEPLOY_STATUS     = 1
	JOB_RUNNING_STATUS    = 2
	JOB_TERMINATED_STATUS = 3
	JOB_COMPLETED_STATUS  = 4
	JOB_FAILED_STATUS     = 5
)
View Source
const (
	DEPLOY_RECEIVE_JOB = iota + 1
	DEPLOY_DOWNLOAD_SOURCE
	DEPLOY_UPLOAD_RESULT
	DEPLOY_BUILD_IMAGE
	DEPLOY_PUSH_IMAGE
	DEPLOY_PULL_IMAGE
)
View Source
const (
	Task_TYPE_FIL_C2 = iota + 1
	Task_TYPE_MINING
	Task_TYPE_AI
	Task_TYPE_INFERENCE
	Task_TYPE_NODE_PORT
	Task_TYPE_EXIT = 100
)
View Source
const (
	NetworkNetset               = "netset-2300e518e9ad45"
	NetworkGlobalSubnet         = "global-e59cad59af9c65"
	NetworkGlobalOutAccess      = "global-pd6sdo8cjd61yd"
	NetworkGlobalInAccess       = "global-01kls78xh7dk4n"
	NetworkGlobalNamespace      = "global-ao9kq72mjc0sl3"
	NetworkGlobalDns            = "global-s92ms87dl3j6do"
	NetworkGlobalPodInNamespace = "global-pod1namespace1"
)
View Source
const (
	MiningJobType    = 1
	InferenceJobType = 2
)
View Source
const (
	FailedStatus     = "failed"
	RejectStatus     = "rejected"
	CreatedStatus    = "created"
	RunningStatus    = "running"
	TerminatedStatus = "terminated"
)
View Source
const (
	ScannerTaskPaymentId = 1
)
View Source
const (
	TaskSequencer = 1
)

Variables

This section is empty.

Functions

func ComputeCompositeHash

func ComputeCompositeHash(files []HashManifestFile) string

ComputeCompositeHash computes a deterministic composite hash from per-file hashes. Algorithm: sort filenames alphabetically, concatenate "filename:hash\n" strings, SHA256 the result. This must match the server-side algorithm in swan-inference.

func DownloadModel

func DownloadModel(ctx context.Context, files []ModelFile, destDir string) error

DownloadModel downloads all model files to destDir. It skips files that already exist with the correct size and hash.

func DownloadModelAndSaveManifest

func DownloadModelAndSaveManifest(ctx context.Context, modelID string, files []ModelFile, destDir string) error

DownloadModelAndSaveManifest downloads a model and saves the hash manifest. This is the recommended entry point for model downloads.

func ExistResource

func ExistResource(name string) bool

func GetDeployStatusStr

func GetDeployStatusStr(deployStatus int) string

func GetJobStatus

func GetJobStatus(status int) string

func GetResourceTypeStr

func GetResourceTypeStr(resourceType int) string

func HuggingFaceModelSize

func HuggingFaceModelSize(files []ModelFile) int64

HuggingFaceModelSize returns the total size of all files.

func JobOnChainStatus

func JobOnChainStatus(status int) string

func SaveHashManifest

func SaveHashManifest(modelID, destDir string, files []ModelFile) error

SaveHashManifest saves a hash manifest for a downloaded model. Should be called after DownloadModel() succeeds.

func TaskStatusStr

func TaskStatusStr(status int) string

func TaskTypeStr

func TaskTypeStr(taskType int) string

func UbiTaskTypeStr

func UbiTaskTypeStr(typeInt int) string

Types

type Account

type Account struct {
	OwnerAddress   string
	NodeId         string
	MultiAddresses []string
	TaskTypes      []uint8 // 1:Fil-C2-512M, 2:mining, 3: AI, 4:Fil-C2-32G 5:NodePort 100:Exit
	Beneficiary    string
	WorkerAddress  string
	Version        string
	Contract       string
}

type CatalogModel

type CatalogModel struct {
	ModelID         string `json:"model_id"`
	Name            string `json:"name"`
	Category        string `json:"category"`
	FileCount       int    `json:"file_count"`
	TotalSizeBytes  int64  `json:"total_size_bytes"`
	WeightSourceURL string `json:"weight_source_url,omitempty"`
}

CatalogModel represents a model available in the Swan Model Repository.

type CatalogResponse

type CatalogResponse struct {
	Models []CatalogModel `json:"models"`
	Total  int            `json:"total"`
}

CatalogResponse is the response from GET /api/v1/models/catalog.

func FetchCatalog

func FetchCatalog(serviceURL string) (*CatalogResponse, error)

FetchCatalog calls the swan-inference API to get the list of available models.

type ClusterResource

type ClusterResource struct {
	NodeId           string          `json:"node_id,omitempty"`
	CpAccountAddress string          `json:"cpAccount_address"`
	Region           string          `json:"region,omitempty"`
	ClusterInfo      []*NodeResource `json:"cluster_info"`
	NodeName         string          `json:"node_name,omitempty"`
	Runtime          string          `json:"runtime,omitempty"`
	ClientType       string          `json:"client_type"`
}

type CollateralContractInfoForECP

type CollateralContractInfoForECP struct {
	CollateralToken string
	WithdrawDelay   int64
}

type CollectNodeInfo

type CollectNodeInfo struct {
	Gpu         Gpu    `json:"gpu"`
	CpuName     string `json:"cpu_name"`
	ProductUuid string `json:"product_uuid"`
	MachineId   string `json:"machine_id"`
}

type Commit1Task

type Commit1Task struct {
	SectorNum  int64      `json:"SectorNum"`
	Phase1Out  string     `json:"Phase1Out"`
	SectorSize uint64     `json:"SectorSize"`
	Sid        SectorRef  `json:"Sid"`
	Ticket     string     `json:"Ticket"`
	Cids       SectorCids `json:"Cids"`
	Seed       Seed       `json:"seed"`
}

type Commit2Proof

type Commit2Proof struct {
	TaskUuid  string `json:"task_uuid"`
	CpAddress string `json:"cp_address"`
	NodeId    string `json:"node_id"`
	TaskId    string `json:"task_id"`
	TaskType  string `json:"task_type"`
	Proof     string `json:"proof"`
}

type Common

type Common struct {
	Total        string `json:"total"`
	Used         string `json:"used"`
	Free         string `json:"free"`
	RemainderNum int64  `json:"-"`
}

type CpBalanceEntity

type CpBalanceEntity struct {
	Id               int64   `json:"id" gorm:"primaryKey"`
	CpAccount        string  `json:"cp_account" gorm:"cp_account"`
	WorkerBalance    float64 `json:"worker_balance" gorm:"worker_balance"`
	SequencerBalance float64 `json:"sequencer_balance" gorm:"sequencer_balance"`
}

func (*CpBalanceEntity) TableName

func (*CpBalanceEntity) TableName() string

type CpCollateralInfoForECP

type CpCollateralInfoForECP struct {
	CpAddress         string
	CollateralBalance string
	FrozenBalance     string
	Status            string
}

type CpInfoEntity

type CpInfoEntity struct {
	Id                 int64    `json:"id" gorm:"primaryKey;autoIncrement"`
	NodeId             string   `json:"node_id" gorm:"node_id"`
	OwnerAddress       string   `json:"owner_address" gorm:"owner_address"`
	Beneficiary        string   `json:"beneficiary" gorm:"beneficiary"`
	WorkerAddress      string   `json:"worker_address" gorm:"worker_address"`
	Version            string   `json:"version" gorm:"version"`
	ContractAddress    string   `json:"contract_address" gorm:"contract_address"`
	MultiAddressesJSON string   `gorm:"multi_addresses_json;type:text" json:"-"`
	TaskTypesJSON      string   `gorm:"task_types_json; type:text" json:"-"`
	CreateAt           string   `json:"create_at" gorm:"create_at"`
	UpdateAt           string   `json:"update_at" gorm:"update_at"`
	MultiAddresses     []string `json:"multi_addresses" gorm:"-"`
	TaskTypes          []uint8  `json:"task_types" gorm:"-"` // 1:Fil-C2-512M, 2:mining, 3: AI, 4:Fil-C2-32G, 5:NodePort, 100:Exit

}

func (*CpInfoEntity) AfterFind

func (c *CpInfoEntity) AfterFind(tx *gorm.DB) (err error)

func (*CpInfoEntity) BeforeSave

func (c *CpInfoEntity) BeforeSave(tx *gorm.DB) (err error)

func (*CpInfoEntity) TableName

func (*CpInfoEntity) TableName() string

type CpuQuota

type CpuQuota struct {
	Quota int64 `json:"quota"`
}

type DeployJobParam

type DeployJobParam struct {
	JobType      int // 1 mining; 2: inference
	Uuid         string
	Name         string
	Image        string
	Cmd          []string
	Ports        []int
	HealthPath   string
	Envs         []string
	NeedResource container.Resources

	BuildImagePath string
	BuildImageName string
	IpWhiteList    []string `json:"ip_white_list"`

	PrepareG []PodGpu
}

type EcpImageJobReq

type EcpImageJobReq struct {
	Uuid          string            `json:"uuid,omitempty"`
	Name          string            `json:"name,omitempty"`
	Price         string            `json:"price,omitempty"`
	Duration      int               `json:"duration,omitempty"`
	JobType       int               `json:"job_type,omitempty"`
	HealthPath    string            `json:"health_path,omitempty"`
	Sign          string            `json:"sign,omitempty"`
	WalletAddress string            `json:"wallet_address,omitempty"`
	Resource      *ResourceInfo     `json:"resource,omitempty"`
	Image         string            `json:"image,omitempty"`
	Cmd           []string          `json:"cmd,omitempty"`
	Ports         map[string][]int  `json:"ports,omitempty"`
	Envs          map[string]string `json:"envs,omitempty"`
	RunCommands   []string          `json:"run_commands,omitempty"`
	ResourceUrl   string            `json:"resource_url,omitempty"`
	WorkDir       string            `json:"work_dir,omitempty"`
	IpWhiteList   []string          `json:"ip_white_list"`
	DeployType    int               `json:"deploy_type"` // 0: field; 1: dockerfile; 2: yaml
	DeployContent string            `json:"deploy_content"`
}

type EcpImageResp

type EcpImageResp struct {
	UUID               string    `json:"uuid,omitempty"`
	ServiceUrl         string    `json:"service_url,omitempty"`
	HealthPath         string    `json:"health_path,omitempty"`
	Price              float64   `json:"price"`
	ServicePortMapping []PortMap `json:"service_port_mapping,omitempty"`
	LogUrl             string    `json:"log_url"`
}

type EcpJobEntity

type EcpJobEntity struct {
	Id              int64   `json:"id" gorm:"primaryKey;autoIncrement"`
	Uuid            string  `json:"uuid" gorm:"uuid"`
	Name            string  `json:"name" gorm:"name"`
	Image           string  `json:"image" gorm:"image"`
	Env             string  `json:"env" gorm:"env"`
	Cmd             string  `json:"cmd" gorm:"type:json"`
	Status          string  `json:"status"` // created|restarting|running|removing|paused|exited|dead
	Message         string  `json:"message"`
	Reward          float64 `json:"reward"`
	Cpu             int64   `json:"cpu"`
	JobType         int     `json:"job_type"`
	Memory          int64   `json:"memory"`
	Storage         int64   `json:"storage"`
	GpuName         string  `json:"gpu_name"`
	GpuIndex        string  `json:"gpu_index"  gorm:"type:json"`          // =
	ContainerName   string  `json:"container_name" gorm:"container_name"` // =
	HealthUrlPath   string  `json:"health_url_path"`
	ServiceUrl      string  `json:"service_url" gorm:"service_url"`
	PortMap         string  `json:"port_map" gorm:"port_map"`
	LastBlockNumber int64   `json:"last_block_number" gorm:"last_block_number"`
	CreateTime      int64   `json:"create_time" gorm:"create_time"`
	DeleteAt        int     `json:"delete_at" gorm:"delete_at; default:0"` // 1 deleted
}

func (*EcpJobEntity) TableName

func (*EcpJobEntity) TableName() string

type EcpJobStatusResp

type EcpJobStatusResp struct {
	Uuid               string    `json:"uuid"`
	Status             string    `json:"status"`
	ServiceUrl         string    `json:"service_url,omitempty"`
	HealthPath         string    `json:"health_path,omitempty"`
	Price              float64   `json:"price"`
	ServicePortMapping []PortMap `json:"service_port_mapping,omitempty"`
	Message            string    `json:"message,omitempty"`
}

type EcpTaskInfo

type EcpTaskInfo struct {
	TaskID               *big.Int
	TaskType             *big.Int
	ResourceType         *big.Int
	InputParam           string
	VerifyParam          string
	CpAccount            common.Address
	Proof                string
	Deadline             *big.Int
	TaskRegistryContract common.Address
	CheckCode            string
	Owner                common.Address
	Version              string
}

type Gpu

type Gpu struct {
	DriverVersion string      `json:"driver_version"`
	CudaVersion   string      `json:"cuda_version"`
	AttachedGpus  int         `json:"attached_gpus"`
	Details       []GpuDetail `json:"details"`
}

type GpuDetail

type GpuDetail struct {
	ProductName   string    `json:"product_name"`
	Status        GpuStatus `json:"status"`
	FbMemoryUsage Common    `json:"fb_memory_usage"`
	OriginalName  string    `json:"original_name"`
	Index         string    `json:"index"`
	Guid          string    `json:"guid"`
}

type GpuQuota

type GpuQuota struct {
	Name  string `json:"name"`
	Quota int64  `json:"quota"`
}

type GpuStatus

type GpuStatus string
const (
	Occupied  GpuStatus = "occupied"
	Available GpuStatus = "available"
)

type HFLFS

type HFLFS struct {
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
}

HFLFS contains LFS metadata for a file.

type HFModelInfo

type HFModelInfo struct {
	Siblings []HFSibling `json:"siblings"`
}

HFModelInfo is the response from the HuggingFace model API.

type HFSibling

type HFSibling struct {
	RFilename string `json:"rfilename"`
	Size      int64  `json:"size"`
	LFS       *HFLFS `json:"lfs,omitempty"`
}

HFSibling represents a file in a HuggingFace model repository.

type HashManifest

type HashManifest struct {
	ModelID       string             `json:"model_id"`
	CompositeHash string             `json:"composite_hash"`
	Algorithm     string             `json:"algorithm"`
	Files         []HashManifestFile `json:"files"`
	CreatedAt     string             `json:"created_at"`
}

HashManifest stores per-file hashes and a composite hash for model weight verification. Saved as .swan-hash-manifest.json in the model directory.

func LoadHashManifest

func LoadHashManifest(destDir string) (*HashManifest, error)

LoadHashManifest loads a hash manifest from a model directory. Returns nil, nil if the manifest does not exist.

type HashManifestFile

type HashManifestFile struct {
	Filename  string `json:"filename"`
	Hash      string `json:"hash"`
	SizeBytes int64  `json:"size_bytes"`
}

HashManifestFile describes a single file's hash in the manifest

type HostInfo

type HostInfo struct {
	SwanProviderVersion string `json:"swan_miner_version"`
	OperatingSystem     string `json:"operating_system"`
	Architecture        string `json:"architecture"`
	CPUCores            int    `json:"cpu_cores"`
}

type Job

type Job struct {
	Uuid   string
	Status int
	Url    string
}

type JobData

type JobData struct {
	UUID                        string   `json:"uuid"`
	Name                        string   `json:"name"`
	Duration                    int      `json:"duration"`
	JobSourceURI                string   `json:"job_source_uri"`
	JobResultURI                string   `json:"job_result_uri,omitempty"`
	StorageSource               string   `json:"storage_source,omitempty"`
	TaskUUID                    string   `json:"task_uuid"`
	BuildLog                    string   `json:"build_log,omitempty"`
	ContainerLog                string   `json:"container_log"`
	NodeIdJobSourceUriSignature string   `json:"node_id_job_source_uri_signature,omitempty"`
	JobRealUri                  string   `json:"job_real_uri,omitempty"`
	JobType                     int      `json:"job_type"`  // 0: Standard job; 1: Custom job
	BidPrice                    string   `json:"bid_price"` // Amount users are willing to pay
	IpWhiteList                 []string `json:"ip_white_list"`
}

type JobEntity

type JobEntity struct {
	Id              int64  `json:"id" gorm:"primaryKey;autoIncrement"`
	Source          string `json:"source" gorm:"source"` // market name
	Name            string `json:"name" gorm:"name"`
	SpaceUuid       string `json:"space_uuid" gorm:"space_uuid"`
	JobUuid         string `json:"job_uuid" gorm:"job_uuid"`
	TaskUuid        string `json:"task_uuid" gorm:"task_uuid"`
	ResourceType    string `json:"resource_type"  gorm:"resource_type"`
	SpaceType       int    `json:"space_type" gorm:"space_type"` // 0: public; 1: private
	SourceUrl       string `json:"source_url" gorm:"source_url"`
	Hardware        string `json:"hardware" gorm:"hardware"`
	Duration        int    `json:"duration" gorm:"duration"`
	DeployStatus    int    `json:"deploy_status" gorm:"deploy_status"`
	WalletAddress   string `json:"wallet_address"  gorm:"wallet_address"`
	ResultUrl       string `json:"result_url" gorm:"result_url"`
	RealUrl         string `json:"real_url" gorm:"real_url"`
	K8sDeployName   string `json:"k8s_deploy_name" gorm:"k8s_deploy_name"`
	K8sResourceType string `json:"k8s_resource_type" gorm:"k8s_resource_type"`
	NameSpace       string `json:"name_space" gorm:"name_space"`
	ImageName       string `json:"image_name" gorm:"image_name"`
	BuildLog        string `json:"build_log" gorm:"build_log"`
	BuildLogPath    string `json:"build_log_path"`
	ContainerLog    string `json:"container_log" gorm:"container_log"`
	Reward          string `json:"reward" gorm:"reward"`
	ExpireTime      int64  `json:"expire_time" gorm:"expire_time"`
	CreateTime      int64  `json:"create_time" gorm:"create_time"`
	Error           string `json:"error" gorm:"error"`
	DeleteAt        int    `json:"delete_at" gorm:"delete_at; default:0"` // 1 deleted
	IpWhiteList     string `json:"ip_white_list"`
	PodStatus       int    `json:"pod_status"`
	Status          int    `json:"status"`
	StartedBlock    uint64 `json:"started_block" gorm:"column:started_block;not null;default:0"`
	ScannedBlock    uint64 `json:"scanned_block" gorm:"column:scanned_block;not null;default:0"`
	EndedBlock      uint64 `json:"ended_block" gorm:"column:ended_block;not null;default:0"`
}

func (*JobEntity) TableName

func (*JobEntity) TableName() string

type ModelFile

type ModelFile struct {
	Filename  string `json:"filename"`
	Hash      string `json:"hash"`
	Algorithm string `json:"algorithm"`
	SizeBytes int64  `json:"size_bytes"`
	URL       string `json:"url"`
}

ModelFile represents a single file in a model's weight repository.

func FetchHuggingFaceFiles

func FetchHuggingFaceFiles(modelID string) ([]ModelFile, error)

FetchHuggingFaceFiles fetches the file list for a model from HuggingFace.

type ModelFilesResponse

type ModelFilesResponse struct {
	ModelID        string      `json:"model_id"`
	Files          []ModelFile `json:"files"`
	TotalSizeBytes int64       `json:"total_size_bytes"`
	FileCount      int         `json:"file_count"`
}

ModelFilesResponse is the response from GET /api/v1/models/:model_id/files.

func FetchModelFiles

func FetchModelFiles(serviceURL, modelID string) (*ModelFilesResponse, error)

FetchModelFiles calls the swan-inference API to get the file manifest for a model.

type NodeResource

type NodeResource struct {
	ProductUuid string `json:"product_uuid"`
	MachineId   string `json:"machine_id"`
	CpuName     string `json:"cpu_name"`
	Cpu         Common `json:"cpu"`
	Vcpu        Common `json:"vcpu"`
	Memory      Common `json:"memory"`
	Gpu         Gpu    `json:"gpu"`
	Storage     Common `json:"storage"`
	Code        string `json:"code"`
}

type PodGpu

type PodGpu struct {
	Gname  string
	Guse   int
	Gindex []string
}

type PortMap

type PortMap struct {
	ContainerPort int `json:"container_port"`
	ExternalPort  int `json:"external_port"`
}

type Quota

type Quota struct {
	Quota int64  `json:"quota"`
	Unit  string `json:"unit"`
}

type Resource

type Resource struct {
	Cpu     Specification
	Memory  Specification
	Gpu     Specification
	Storage Specification
}

type ResourceInfo

type ResourceInfo struct {
	CPU     int64 `json:"cpu"`
	Memory  int64 `json:"memory"`  // bytes
	Storage int64 `json:"storage"` // bytes
	Gpus    []struct {
		GPU      int    `json:"gpu"`
		GPUModel string `json:"gpu_model"`
	} `json:"gpus"`
}

type ResourcePolicy

type ResourcePolicy struct {
	Cpu     CpuQuota   `json:"cpu"`
	Gpu     []GpuQuota `json:"gpu"`
	Memory  Quota      `json:"memory"`
	Storage Quota      `json:"storage"`
}

type ResourcePrice

type ResourcePrice struct {
	CpuPrice         string            `json:"cpu_price"`
	MemoryPrice      string            `json:"memory_price"`
	HdEphemeralPrice string            `json:"hd_ephemeral_price"`
	HdPersHddPrice   string            `json:"hd_pers_hdd_price,omitempty"`
	HdPersSsdPrice   string            `json:"hd_pers_ssd_price,omitempty"`
	HdPersNvmePrice  string            `json:"hd_pers_nvme_price,omitempty"`
	GpuDefaultPrice  string            `json:"gpu_default_price"`
	GpusPrice        map[string]string `json:"gpus_price"`
	Pricing          bool              `json:"pricing"`
}

type ResourceStatus

type ResourceStatus struct {
	Request  int64
	Capacity int64
}

type ScanChainEntity

type ScanChainEntity struct {
	Id          int64  `json:"id" gorm:"primaryKey"`
	BlockNumber int64  `json:"block_number" gorm:"block_number"`
	UpdateTime  string `json:"update_time" gorm:"update_time"`
}

func (*ScanChainEntity) TableName

func (*ScanChainEntity) TableName() string

type SectorCids

type SectorCids struct {
	Unsealed struct {
		Field1 string `json:"/"`
	} `json:"Unsealed"`
	Sealed struct {
		Field1 string `json:"/"`
	} `json:"Sealed"`
}

type SectorRef

type SectorRef struct {
	ID struct {
		Miner  uint64 `json:"Miner"`
		Number uint64 `json:"Number"`
	} `json:"ID"`
	ProofType int64 `json:"ProofType"`
}

type Seed

type Seed struct {
	Value string `json:"Value"`
	Epoch int    `json:"Epoch"`
}

type SpaceFile

type SpaceFile struct {
	Name         string `json:"name"`
	URL          string `json:"url"`
	SymmetricKey string `json:"symmetric_key"`
	Iv           string `json:"iv"`
}

type SpaceHardware

type SpaceHardware struct {
	Description  string `json:"description"`
	HardwareType string `json:"hardware_type"`
	Hardware     string `json:"hardware"` // Nvidia 3080  CPU only
	Memory       int64  `json:"memory"`   // unit bytes
	Name         string `json:"name"`
	Vcpu         int64  `json:"vcpu"`
	Storage      int64  `json:"storage"` // unit bytes
	Gpu          int64  `json:"gpu"`
}

type SpaceJSON

type SpaceJSON struct {
	Data    SpaceJsonWithNoData `json:"data"`
	Message string              `json:"message"`
	Status  string              `json:"status"`
}

type SpaceJsonWithNoData

type SpaceJsonWithNoData struct {
	Files []SpaceFile `json:"files"`
	Owner struct {
		PublicAddress string `json:"public_address"`
	} `json:"owner"`
	Space struct {
		Uuid        string `json:"uuid"`
		Name        string `json:"name"`
		ActiveOrder struct {
			Config SpaceHardware `json:"config"`
		} `json:"activeOrder"`
	} `json:"space"`
}

type Specification

type Specification struct {
	Quantity int64
	Unit     string
}

type TaskEntity

type TaskEntity struct {
	Id                 int64  `json:"id" gorm:"primaryKey;id"`
	Uuid               string `json:"uuid"`
	Type               int    `json:"type" gorm:"type"`
	Name               string `json:"name" gorm:"name"`
	Contract           string `json:"contract" gorm:"contract"`
	ResourceType       int    `json:"resource_type" gorm:"resource_type"` // 1
	InputParam         string `json:"input_param" gorm:"input_param"`
	VerifyParam        string `json:"verify_param" gorm:"verify_param"`
	TxHash             string `json:"tx_hash" gorm:"tx_hash"`
	Status             int    `json:"status" gorm:"status"`
	CreateTime         int64  `json:"create_time" gorm:"create_time"`
	EndTime            int64  `json:"end_time" gorm:"end_time"`
	Error              string `json:"error" gorm:"error"`
	Deadline           int64  `json:"deadline"`
	CheckCode          string `json:"check_code"`
	BlockHash          string `json:"block_hash"`
	Sign               string `json:"sign"`
	Reward             string `json:"reward"`
	SequenceCid        string `json:"sequence_cid"`
	SettlementCid      string `json:"settlement_cid"`
	SequenceTaskAddr   string `json:"sequence_task_addr"`
	SettlementTaskAddr string `json:"settlement_task_addr"`
	Sequencer          int    `json:"sequencer" gorm:"default:-1"`
	Proof              string
}

func (*TaskEntity) TableName

func (task *TaskEntity) TableName() string

type TaskResource

type TaskResource struct {
	CPU       string `json:"cpu"`
	Gpu       string `json:"gpu"`
	GpuDetail struct {
		ProductName string `json:"product_name"`
		Count       string `json:"count"`
	} `json:"gpu_detail"`
	Memory  string `json:"memory"`
	Storage string `json:"storage"`
}

type UBITaskReq

type UBITaskReq struct {
	ID           int           `json:"id"`
	Name         string        `json:"name,omitempty"`
	Type         int           `json:"type"`
	InputParam   string        `json:"input_param"`
	VerifyParam  string        `json:"verify_param"`
	Signature    string        `json:"signature"`
	Resource     *TaskResource `json:"resource"`
	ResourceType int           `json:"resource_type"`
	DeadLine     int64         `json:"deadline"`
	CheckCode    string        `json:"check_code"`
}

type UbiC2Proof

type UbiC2Proof struct {
	TaskId    string `json:"task_id,omitempty"`
	TaskType  string `json:"task_type,omitempty"`
	Proof     string `json:"proof,omitempty"`
	ZkType    string `json:"zk_type,omitempty"`
	NameSpace string `json:"name_space,omitempty"`
}

type VerifyResult

type VerifyResult struct {
	Filename string
	Status   string // "pass", "fail", "missing"
	Expected string
	Actual   string
}

VerifyResult describes the result of verifying a single file.

func VerifyModel

func VerifyModel(files []ModelFile, destDir string) []VerifyResult

VerifyModel checks each local file against expected hashes.

type WithdrawRequest

type WithdrawRequest struct {
	Amount        string
	RequestBlock  int64
	WithdrawDelay int64
}

type ZkTaskReq

type ZkTaskReq struct {
	Id          int           `json:"id"`
	Uuid        string        `json:"uuid,omitempty"`
	Name        string        `json:"name,omitempty"`
	TaskType    int           `json:"task_type"` // 1: fil-c2-512-cpu; 2:fil-c2-32-cpu; 3: fil-c2-512-gpu; 4: fil-c2-32-gpu; 5: mining
	InputParam  string        `json:"input_param"`
	VerifyParam string        `json:"verify_param"`
	Signature   string        `json:"signature"`
	Resource    *ResourceInfo `json:"resource"`
	DeadLine    int64         `json:"deadline"`
	CheckCode   string        `json:"check_code"`

	Image string            `json:"image,omitempty"`
	Cmd   []string          `json:"cmd,omitempty"`
	Ports map[string][]int  `json:"ports,omitempty"`
	Envs  map[string]string `json:"envs,omitempty"`
}

Jump to

Keyboard shortcuts

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