Documentation ¶
Index ¶
- func InitTables(d *SQLDB, serverID dtypes.ServerID) error
- type SQLDB
- func (n *SQLDB) AssetExists(hash string, serverID dtypes.ServerID) (bool, error)
- func (n *SQLDB) BatchInitReplicas(infos []*types.ReplicaInfo) error
- func (n *SQLDB) DeleteAssetRecord(hash string, serverID dtypes.ServerID, info *types.AssetEventInfo) error
- func (n *SQLDB) DeleteAssetReplica(hash, nodeID string, info *types.AssetEventInfo) error
- func (n *SQLDB) DeleteAssetsView(nodeID string) error
- func (n *SQLDB) DeleteBucket(bucketID string) error
- func (n *SQLDB) DeleteEdgeUpdateConfig(nodeType int) error
- func (n *SQLDB) DeleteNodeInfo(nodeID string) error
- func (n *SQLDB) DeleteUnfinishedReplicas(hash string) error
- func (n *SQLDB) IsValidator(nodeID string) (bool, error)
- func (n *SQLDB) LoadAllAssetRecords(serverID dtypes.ServerID) (*sqlx.Rows, error)
- func (n *SQLDB) LoadAssetCount(serverID dtypes.ServerID) (int, error)
- func (n *SQLDB) LoadAssetRecord(hash string) (*types.AssetRecord, error)
- func (n *SQLDB) LoadAssetRecords(statuses []string, limit, offset int, serverID dtypes.ServerID) (*sqlx.Rows, error)
- func (n *SQLDB) LoadAssetReplicas(hash string) ([]*types.ReplicaInfo, error)
- func (n *SQLDB) LoadAssetState(hash string, serverID dtypes.ServerID) (*types.AssetStateInfo, error)
- func (n *SQLDB) LoadBucket(bucketID string) ([]byte, error)
- func (n *SQLDB) LoadBucketHashes(nodeID string) ([]byte, error)
- func (n *SQLDB) LoadEdgeUpdateConfigs() (map[int]*api.EdgeUpdateConfig, error)
- func (n *SQLDB) LoadExpiredAssetRecords(serverID dtypes.ServerID) ([]*types.AssetRecord, error)
- func (n *SQLDB) LoadNodeInfo(nodeID string) (*types.NodeInfo, error)
- func (n *SQLDB) LoadNodeInfos(limit, offset int) (*sqlx.Rows, int64, error)
- func (n *SQLDB) LoadNodeLastSeenTime(nodeID string) (time.Time, error)
- func (n *SQLDB) LoadNodeOnlineDuration(nodeID string) (int, error)
- func (n *SQLDB) LoadNodePublicKey(nodeID string) (string, error)
- func (n *SQLDB) LoadNodeType(nodeID string) (types.NodeType, error)
- func (n *SQLDB) LoadNodeValidationInfo(roundID, nodeID string) (*types.ValidationResultInfo, error)
- func (n *SQLDB) LoadPortMapping(nodeID string) (string, error)
- func (n *SQLDB) LoadReplicas(startTime time.Time, endTime time.Time, cursor, count int) (*types.ListReplicaInfosRsp, error)
- func (n *SQLDB) LoadReplicasByHash(hash string, statuses []types.ReplicaStatus) (*sqlx.Rows, error)
- func (n *SQLDB) LoadSucceededReplicaCount() (int, error)
- func (n *SQLDB) LoadTokenPayloadAndWorkloads(tokenID string, isClient bool) (*types.TokenPayload, []byte, error)
- func (n *SQLDB) LoadTopHash(nodeID string) (string, error)
- func (n *SQLDB) LoadUnfinishedPullAssetNodes(hash string) ([]string, error)
- func (n *SQLDB) LoadValidationResultInfos(startTime, endTime time.Time, pageNumber, pageSize int) (*types.ListValidationResultRsp, error)
- func (n *SQLDB) LoadValidationResults(maxTime time.Time, limit int) (*sqlx.Rows, error)
- func (n *SQLDB) LoadValidators(serverID dtypes.ServerID) ([]string, error)
- func (n *SQLDB) NodeExists(nodeID string, nodeType types.NodeType) error
- func (n *SQLDB) SaveAssetRecord(rInfo *types.AssetRecord, eInfo *types.AssetEventInfo) error
- func (n *SQLDB) SaveAssetsView(nodeID string, topHash string, bucketHashes []byte) error
- func (n *SQLDB) SaveBucket(bucketID string, assetHashes []byte) error
- func (n *SQLDB) SaveEdgeUpdateConfig(info *api.EdgeUpdateConfig) error
- func (n *SQLDB) SaveNodeInfo(info *types.NodeInfo) error
- func (n *SQLDB) SaveNodeProfit(nodeID string, cProfit float64) (oldProfit, newValue float64, err error)
- func (n *SQLDB) SaveNodeRegisterInfo(pKey, nodeID string, nodeType types.NodeType) error
- func (n *SQLDB) SaveTokenPayload(tks []*types.TokenPayload) error
- func (n *SQLDB) SaveValidationResultInfos(infos []*types.ValidationResultInfo) error
- func (n *SQLDB) UpdateAssetRecordExpiry(hash string, eTime time.Time, serverID dtypes.ServerID) error
- func (n *SQLDB) UpdateNodeOnlineTime(nodeID string, onlineTime int) error
- func (n *SQLDB) UpdateNodeProfitsByValidationResult(vIDs []int, nodeProfits map[string]float64) error
- func (n *SQLDB) UpdatePortMapping(nodeID, port string) error
- func (n *SQLDB) UpdateReplicasStatusToFailed(hash string) error
- func (n *SQLDB) UpdateStateOfAsset(hash, state string, totalBlock, totalSize, retryCount, replenishReplicas int64, ...) error
- func (n *SQLDB) UpdateUnfinishedReplica(cInfo *types.ReplicaInfo) error
- func (n *SQLDB) UpdateValidationResultInfo(info *types.ValidationResultInfo) error
- func (n *SQLDB) UpdateValidationResultProfit(id int, profit float64) error
- func (n *SQLDB) UpdateValidationResultsTimeout(roundID string) error
- func (n *SQLDB) UpdateValidatorInfo(serverID dtypes.ServerID, nodeID string) error
- func (n *SQLDB) UpdateValidators(nodeIDs []string, serverID dtypes.ServerID) error
- func (n *SQLDB) UpdateWorkloadReport(tokenID string, isClient bool, workloads []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SQLDB ¶
type SQLDB struct {
// contains filtered or unexported fields
}
SQLDB represents a scheduler sql database.
func (*SQLDB) AssetExists ¶
AssetExists checks if an asset exists in the state machine table of the specified server.
func (*SQLDB) BatchInitReplicas ¶
func (n *SQLDB) BatchInitReplicas(infos []*types.ReplicaInfo) error
BatchInitReplicas inserts or updates replica information in batch
func (*SQLDB) DeleteAssetRecord ¶
func (n *SQLDB) DeleteAssetRecord(hash string, serverID dtypes.ServerID, info *types.AssetEventInfo) error
DeleteAssetRecord removes all records associated with a given asset hash from the database.
func (*SQLDB) DeleteAssetReplica ¶
func (n *SQLDB) DeleteAssetReplica(hash, nodeID string, info *types.AssetEventInfo) error
DeleteAssetReplica remove a replica associated with a given asset hash from the database.
func (*SQLDB) DeleteAssetsView ¶
DeleteAssetsView delete the asset view for node
func (*SQLDB) DeleteBucket ¶
DeleteBucket delete the bucket
func (*SQLDB) DeleteEdgeUpdateConfig ¶
DeleteEdgeUpdateConfig delete edge update info
func (*SQLDB) DeleteNodeInfo ¶
DeleteNodeInfo delete Node info
func (*SQLDB) DeleteUnfinishedReplicas ¶
DeleteUnfinishedReplicas deletes the incomplete replicas with the given hash from the database.
func (*SQLDB) IsValidator ¶
IsValidator Determine whether the node is a validator
func (*SQLDB) LoadAllAssetRecords ¶
LoadAllAssetRecords loads all asset records for a given server ID.
func (*SQLDB) LoadAssetCount ¶
LoadAssetCount count asset
func (*SQLDB) LoadAssetRecord ¶
func (n *SQLDB) LoadAssetRecord(hash string) (*types.AssetRecord, error)
LoadAssetRecord load asset record information
func (*SQLDB) LoadAssetRecords ¶
func (n *SQLDB) LoadAssetRecords(statuses []string, limit, offset int, serverID dtypes.ServerID) (*sqlx.Rows, error)
LoadAssetRecords load the asset records from the incoming scheduler
func (*SQLDB) LoadAssetReplicas ¶
func (n *SQLDB) LoadAssetReplicas(hash string) ([]*types.ReplicaInfo, error)
LoadAssetReplicas load asset replica information based on hash.
func (*SQLDB) LoadAssetState ¶
func (n *SQLDB) LoadAssetState(hash string, serverID dtypes.ServerID) (*types.AssetStateInfo, error)
LoadAssetState loads the state of the asset for a given server ID.
func (*SQLDB) LoadBucket ¶
LoadBucket load assets ids from bucket return hashes of asset
func (*SQLDB) LoadBucketHashes ¶
LoadBucketHashes load assets view buckets hashes
func (*SQLDB) LoadEdgeUpdateConfigs ¶
func (n *SQLDB) LoadEdgeUpdateConfigs() (map[int]*api.EdgeUpdateConfig, error)
LoadEdgeUpdateConfigs load edge update information.
func (*SQLDB) LoadExpiredAssetRecords ¶
LoadExpiredAssetRecords load all expired asset records based on serverID.
func (*SQLDB) LoadNodeInfo ¶
LoadNodeInfo load node information.
func (*SQLDB) LoadNodeInfos ¶
LoadNodeInfos load nodes information.
func (*SQLDB) LoadNodeLastSeenTime ¶
LoadNodeLastSeenTime loads the last seen time of a node
func (*SQLDB) LoadNodeOnlineDuration ¶
LoadNodeOnlineDuration load online duration of node.
func (*SQLDB) LoadNodePublicKey ¶
LoadNodePublicKey load public key of node.
func (*SQLDB) LoadNodeType ¶
LoadNodeType load type of node.
func (*SQLDB) LoadNodeValidationInfo ¶
func (n *SQLDB) LoadNodeValidationInfo(roundID, nodeID string) (*types.ValidationResultInfo, error)
LoadNodeValidationInfo load the cid of a validation result.
func (*SQLDB) LoadPortMapping ¶
LoadPortMapping load the mapping port of a node.
func (*SQLDB) LoadReplicas ¶
func (n *SQLDB) LoadReplicas(startTime time.Time, endTime time.Time, cursor, count int) (*types.ListReplicaInfosRsp, error)
LoadReplicas load information about all replicas whose end_time is between startTime and endTime, limited to "count" results and starting from "cursor".
func (*SQLDB) LoadReplicasByHash ¶
LoadReplicasByHash load asset replica information based on hash and statuses.
func (*SQLDB) LoadSucceededReplicaCount ¶
LoadSucceededReplicaCount retrieves the succeeded replica count
func (*SQLDB) LoadTokenPayloadAndWorkloads ¶
func (*SQLDB) LoadTopHash ¶
LoadTopHash load assets view top hash
func (*SQLDB) LoadUnfinishedPullAssetNodes ¶
LoadUnfinishedPullAssetNodes retrieves the node IDs for all nodes that have not yet finished pulling an asset for a given asset hash.
func (*SQLDB) LoadValidationResultInfos ¶
func (n *SQLDB) LoadValidationResultInfos(startTime, endTime time.Time, pageNumber, pageSize int) (*types.ListValidationResultRsp, error)
LoadValidationResultInfos load validation results.
func (*SQLDB) LoadValidationResults ¶
LoadValidationResults Load unprocessed validation results
func (*SQLDB) LoadValidators ¶
LoadValidators load validators information.
func (*SQLDB) NodeExists ¶
NodeExists is node exists
func (*SQLDB) SaveAssetRecord ¶
func (n *SQLDB) SaveAssetRecord(rInfo *types.AssetRecord, eInfo *types.AssetEventInfo) error
SaveAssetRecord saves an asset record into the database.
func (*SQLDB) SaveAssetsView ¶
TODO save bucketHashes as array SaveAssetsView update or insert top hash and buckets hashes to assets view bucketHashes key is number of bucket, value is bucket hash
func (*SQLDB) SaveBucket ¶
SaveBucket update or insert assets ids to bucket
func (*SQLDB) SaveEdgeUpdateConfig ¶
func (n *SQLDB) SaveEdgeUpdateConfig(info *api.EdgeUpdateConfig) error
SaveEdgeUpdateConfig inserts edge update information.
func (*SQLDB) SaveNodeInfo ¶
SaveNodeInfo Insert or update node info
func (*SQLDB) SaveNodeProfit ¶
func (n *SQLDB) SaveNodeProfit(nodeID string, cProfit float64) (oldProfit, newValue float64, err error)
SaveNodeProfit Modify and return the node profit value
func (*SQLDB) SaveNodeRegisterInfo ¶
SaveNodeRegisterInfo Insert Node register info
func (*SQLDB) SaveTokenPayload ¶
func (n *SQLDB) SaveTokenPayload(tks []*types.TokenPayload) error
func (*SQLDB) SaveValidationResultInfos ¶
func (n *SQLDB) SaveValidationResultInfos(infos []*types.ValidationResultInfo) error
SaveValidationResultInfos inserts validation result information.
func (*SQLDB) UpdateAssetRecordExpiry ¶
func (n *SQLDB) UpdateAssetRecordExpiry(hash string, eTime time.Time, serverID dtypes.ServerID) error
UpdateAssetRecordExpiry resets asset record expiration time based on hash and eTime
func (*SQLDB) UpdateNodeOnlineTime ¶
UpdateNodeOnlineTime update node online time and last time
func (*SQLDB) UpdateNodeProfitsByValidationResult ¶
func (n *SQLDB) UpdateNodeProfitsByValidationResult(vIDs []int, nodeProfits map[string]float64) error
UpdateNodeProfitsByValidationResult Update the gain value of the node, and set the processed flag to the validation record
func (*SQLDB) UpdatePortMapping ¶
UpdatePortMapping sets the node's mapping port.
func (*SQLDB) UpdateReplicasStatusToFailed ¶
UpdateReplicasStatusToFailed updates the status of unfinished asset replicas
func (*SQLDB) UpdateStateOfAsset ¶
func (n *SQLDB) UpdateStateOfAsset(hash, state string, totalBlock, totalSize, retryCount, replenishReplicas int64, serverID dtypes.ServerID) error
UpdateStateOfAsset update asset state information
func (*SQLDB) UpdateUnfinishedReplica ¶
func (n *SQLDB) UpdateUnfinishedReplica(cInfo *types.ReplicaInfo) error
UpdateUnfinishedReplica update unfinished replica info , return an error if the replica is finished
func (*SQLDB) UpdateValidationResultInfo ¶
func (n *SQLDB) UpdateValidationResultInfo(info *types.ValidationResultInfo) error
UpdateValidationResultInfo updates the validation result information.
func (*SQLDB) UpdateValidationResultProfit ¶
UpdateValidationResultProfit update profit for node validation
func (*SQLDB) UpdateValidationResultsTimeout ¶
UpdateValidationResultsTimeout sets the validation results' status as timeout.
func (*SQLDB) UpdateValidatorInfo ¶
UpdateValidatorInfo reset scheduler server id for validator
func (*SQLDB) UpdateValidators ¶
UpdateValidators update validators