tsproto

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FRAGMENT_SIZE   = 8 * 1024 * 1024
	NODE_STATUS_URL = "/status"
	CLAIM_DATA_URL  = "/claim"
	PUSH_DATA_URL   = "/provide"
	FETCH_DATA_URL  = "/fetch"
)
View Source
const (
	SUCCESS_MESSAGE = "success"
	ERROR_MESSAGE   = "error"

	QUERY_DATA_INFO_URL  = "/getinfo"
	FETCH_CACHE_DATA_URL = "/cache-fetch"
	QUERY_CAPACITY_URL   = "/download_traffic_query"
	AUDIT_DATA_URL       = "/audit"
	QUERY_TEE_INFO       = "/query_information"
)

Justicar API URL

Variables

This section is empty.

Functions

func AuditData

func AuditData(url, fpath, rpath string, req TeeReq) error

func CheckStorageNodeAvailable

func CheckStorageNodeAvailable(baseUrl string) error

func ClaimOffloadingData

func ClaimOffloadingData(url string, req FileRequest) ([]byte, string, error)

func FetchDataAndFlag added in v0.1.2

func FetchDataAndFlag(gatewayUrl, token, fid, did string) (string, []byte, error)

func FetchFile

func FetchFile(gatewayUrl, token, fid, did string) ([]byte, error)

func GetFileFromStorageNode

func GetFileFromStorageNode(url, acc, message, sign, fid, fragment, path string) error

func PushFile

func PushFile(url, fpath string, metaDatas map[string][]byte) ([]byte, error)

func PushFileToStorageNode

func PushFileToStorageNode(url, acc, message, sign, fid, fragment, path string) error

func QueryRemainCap

func QueryRemainCap(url, requester string) (uint64, error)

func RechargeCapacity

func RechargeCapacity(url, requester string, orderId [32]byte) error

func SendHttpRequest

func SendHttpRequest(method, url string, headers map[string]string, dataReader *bytes.Buffer) ([]byte, error)

Types

type CacheRequest

type CacheRequest struct {
	Did       string `json:"did"`
	UserAddr  string `json:"user_addr"`
	RequestId string `json:"requestId"`
	ExtData   string `json:"extdata"`
	Sign      []byte `json:"sign"`
	Exp       int64  `json:"expiration"`
}

type Cd2nNode

type Cd2nNode struct {
	Version            string   `json:"version"`
	WorkAddr           string   `json:"work_addr"`
	TeeAddr            string   `json:"tee_addr"`
	TeePubkey          []byte   `json:"tee_pubkey"`
	EndPoint           string   `json:"endpoint"`
	RedisAddr          string   `json:"redis_addr"`
	PoolId             string   `json:"poolid"`
	IsGateway          bool     `json:"is_gateway"`
	ActiveStorageNodes []string `json:"active_storage_nodes"`
	Status             `json:"status"`
}

func CheckCdnNodeAvailable

func CheckCdnNodeAvailable(baseUrl string) (Cd2nNode, error)

type DiskStatus

type DiskStatus struct {
	UsedCacheSize  uint64  `json:"used_cache_size"`
	CacheItemNum   uint64  `json:"cache_item_num"`
	CacheUsage     float32 `json:"cache_usage"`
	UsedBufferSize uint64  `json:"used_buffer_size"`
	BufferItemNum  uint64  `json:"buffer_item_num"`
	BufferUsage    float32 `json:"buffer_usage"`
}

type DistStatus

type DistStatus struct {
	Ongoing uint64 `json:"ongoing"`
	Done    uint64 `json:"done"`
	Retried uint64 `json:"retried"`
	FidNum  uint64 `json:"fid_num"`
}

type DownloadStatus

type DownloadStatus struct {
	DlingNum uint64 `json:"dling_num"`
}

type FileMeta

type FileMeta struct {
	Tid       string `json:"tid"`
	Did       string `json:"did"`
	Size      int64  `json:"size"`
	Key       string `json:"key"`
	Provider  string `json:"provider"`
	Timestamp string `json:"timestamp"`
}

type FileRequest

type FileRequest struct {
	Pubkey       []byte        `json:"pubkey"`
	Fid          string        `json:"fid"`
	Timestamp    string        `json:"timestamp"`
	StorageNodes []StorageNode `json:"storage_nodes"`
	Sign         string        `json:"sign"`
}

type FileResponse

type FileResponse struct {
	Fid       string   `json:"fid"`
	Fragments []string `json:"fragments"`
	Token     string   `json:"token"`
}

func ClaimFile

func ClaimFile(url string, req FileRequest) (FileResponse, error)

type Response

type Response struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data"`
}

func NewResponse

func NewResponse(code int, msg string, data any) Response

func (Response) Error

func (r Response) Error() error

func (Response) Result

func (r Response) Result() any

func (Response) Status

func (r Response) Status() int

type RetrieveStatus

type RetrieveStatus struct {
	NTBR         uint64 `json:"ntbr"`
	RetrieveNum  uint64 `json:"retrieve_num"`
	RetrievedNum uint64 `json:"retrieved_num"`
}

type Status

type Status struct {
	DiskStatus     `json:"disk_status"`
	DistStatus     `json:"dist_status"`
	RetrieveStatus `json:"retrieve_status"`
	DownloadStatus `json:"download_status"`
}

type StorageNode

type StorageNode struct {
	Account  string `json:"account"`
	Endpoint string `json:"endpoint"`
}

type TeeReq

type TeeReq struct {
	Cid         string `json:"cid,omitempty"`
	UserAcc     string `json:"user_eth_address,omitempty"`
	Key         []byte `json:"key,omitempty"`
	UserSign    []byte `json:"user_sign"`
	SupplierAcc string `json:"supplier_acc,omitempty"`
	OrderId     []byte `json:"oid,omitempty"`
	RequestId   string `json:"requestId,omitempty"`
	Nonce       []byte `json:"nonce,omitempty"`
	Data        []byte `json:"data,omitempty"`
}

type TeeResp

type TeeResp struct {
	Msg        string `json:"msg"`
	RemainCap  uint64 `json:"left_user_download_traffic"`
	EthAddress string `json:"eth_address"`
	Pubkey     []byte `json:"secp256k1_public_key"`
	UserAcc    string `json:"user_eth_address"`
	Data       any    `json:"data"`
}

func QueryTeeInfo

func QueryTeeInfo(url string) (TeeResp, error)

Jump to

Keyboard shortcuts

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