asset

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRandomCheck

func NewRandomCheck(randomSeed int64, storage storage.Storage, lru *lruCache) (*randomCheck, error)

NewRandomCheck creates a new instance of randomCheck

Types

type Asset

type Asset struct {
	TotalBlockCount int
	// contains filtered or unexported fields
}

func NewAsset

func NewAsset(storageMgr *storage.Manager, scheduler api.Scheduler, assetMgr *Manager) *Asset

NewAsset creates a new Asset instance

func (*Asset) BlockCountOfAsset

func (a *Asset) BlockCountOfAsset(assetCID string) (int, error)

BlockCountOfAsset returns the block count for the given asset.

func (*Asset) DeleteAsset

func (a *Asset) DeleteAsset(ctx context.Context, assetCID string) error

DeleteAsset deletes the asset with the given CID

func (*Asset) GetAssetProgresses

func (a *Asset) GetAssetProgresses(ctx context.Context, assetCIDs []string) (*types.PullResult, error)

GetAssetProgresses returns the progress of the given list of assets.

func (*Asset) GetAssetStats

func (a *Asset) GetAssetStats(ctx context.Context) (*types.AssetStats, error)

GetAssetStats returns statistics about the assets stored on this node

func (*Asset) GetBlocksOfAsset

func (a *Asset) GetBlocksOfAsset(assetCID string, randomSeed int64, randomCount int) ([]string, error)

GetBlocksOfAsset returns a random subset of blocks for the given asset.

func (*Asset) GetPullingAssetInfo

func (a *Asset) GetPullingAssetInfo(ctx context.Context) (*types.InProgressAsset, error)

GetPullingAssetInfo returns information about the asset currently being pulled

func (*Asset) PullAsset

func (a *Asset) PullAsset(ctx context.Context, rootCID string, infos []*types.CandidateDownloadInfo) error

PullAsset adds the asset to the waitList for pulling

type AssetPullerEncoder

type AssetPullerEncoder struct {
	Root                    string
	BlocksWaitList          []string
	BlocksPulledSuccessList []string
	NextLayerCIDs           []string
	DownloadSources         []*types.CandidateDownloadInfo
	TotalSize               uint64
	DoneSize                uint64
}

AssetPullerEncoder encodes or decodes assetPuller

type Key

type Key string

type Manager

type Manager struct {
	storage.Storage
	api.Scheduler
	// contains filtered or unexported fields
}

Manager is the struct that manages asset pulling and store

func NewManager

func NewManager(opts *ManagerOptions) (*Manager, error)

NewManager creates a new instance of Manager

func (*Manager) AddLostAsset

func (m *Manager) AddLostAsset(root cid.Cid) error

AddLostAsset adds a lost asset to the Manager's waitList if it is not already present in the storage

func (*Manager) DeleteAsset

func (m *Manager) DeleteAsset(root cid.Cid) error

DeleteAsset removes an asset from the datastore and the waitList.

func (*Manager) GetAssetForValidation

func (m *Manager) GetAssetForValidation(ctx context.Context, randomSeed int64) (validate.Asset, error)

GetAssetForValidation returns a new instance of asset based on a given random seed

func (*Manager) GetAssetsOfBucket

func (m *Manager) GetAssetsOfBucket(ctx context.Context, bucketID uint32, isRemote bool) ([]cid.Cid, error)

GetAssetsOfBucket retrieves the list of assets in a given bucket ID from the storage

func (*Manager) GetBlock

func (m *Manager) GetBlock(ctx context.Context, root, block cid.Cid) (blocks.Block, error)

GetBlock returns the block with the given CID from the LRU cache

func (*Manager) GetBlocksOfAsset

func (m *Manager) GetBlocksOfAsset(root cid.Cid, randomSeed int64, randomCount int) ([]string, error)

GetBlocksOfAsset returns a random selection of blocks for the given root CID return map, key is random number, value is cid string

func (*Manager) HasBlock

func (m *Manager) HasBlock(ctx context.Context, root, block cid.Cid) (bool, error)

HasBlock checks if a block with the given CID exists in the LRU cache

func (*Manager) ScanBlocks

func (m *Manager) ScanBlocks(ctx context.Context, root cid.Cid) error

type ManagerOptions

type ManagerOptions struct {
	Storage      storage.Storage
	BFetcher     fetcher.BlockFetcher
	SchedulerAPI api.Scheduler
	PullParallel int
	PullTimeout  int
	PullRetry    int
}

ManagerOptions is the struct that contains options for Manager

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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