progress

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// PieceRunning means that the pieces is being downloaded.
	PieceRunning = "running"

	// PieceSuccess means that the piece has been downloaded successful.
	PieceSuccess = "success"

	// PieceAvailable means that the piece has neither been downloaded successfully
	// nor being downloaded and supernode has downloaded it successfully.
	PieceAvailable = "available"
)

PieceStatus which is used for GetPieceByCID.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is an implementation of the interface of ProgressMgr.

func NewManager

func NewManager(cfg *config.Config) (*Manager, error)

NewManager returns a new Manager.

func (*Manager) DeletePeerIDByPieceNum

func (pm *Manager) DeletePeerIDByPieceNum(ctx context.Context, taskID string, pieceNum int, peerID string) error

DeletePeerIDByPieceNum deletes the peerID which means that the peer no longer provides the service for the pieceNum of taskID.

func (*Manager) DeletePeerStateByPeerID

func (pm *Manager) DeletePeerStateByPeerID(ctx context.Context, peerID string) error

DeletePeerStateByPeerID deletes the peerState by PeerID.

func (*Manager) DeletePieceProgressByCID

func (pm *Manager) DeletePieceProgressByCID(ctx context.Context, taskID, clientID string) (err error)

DeletePieceProgressByCID deletes the pieces progress with specified clientID.

func (*Manager) GetBlackInfoByPeerID

func (pm *Manager) GetBlackInfoByPeerID(ctx context.Context, peerID string) (dstPIDMap *cutil.SyncMap, err error)

GetBlackInfoByPeerID gets black info with specified peerID.

func (*Manager) GetPeerIDsByPieceNum

func (pm *Manager) GetPeerIDsByPieceNum(ctx context.Context, taskID string, pieceNum int) (peerIDs []string, err error)

GetPeerIDsByPieceNum gets all peerIDs with specified taskID and pieceNum. It will return nil when no peers is available.

func (*Manager) GetPeerStateByPeerID

func (pm *Manager) GetPeerStateByPeerID(ctx context.Context, peerID string) (*mgr.PeerState, error)

GetPeerStateByPeerID gets peer state with specified peerID.

func (*Manager) GetPeersByTaskID

func (pm *Manager) GetPeersByTaskID(ctx context.Context, taskID string) (peersInfo []*types.PeerInfo, err error)

GetPeersByTaskID gets all peers info with specified taskID.

func (*Manager) GetPieceProgressByCID

func (pm *Manager) GetPieceProgressByCID(ctx context.Context, taskID, clientID, pieceStatus string) (pieceNums []int, err error)

GetPieceProgressByCID gets all pieces with specified clientID.

And the pieceStatus should be one of the `PieceRunning`,`PieceSuccess` and `PieceAvailable`. If not, the `PieceAvailable` will be as the default value.

func (*Manager) InitProgress

func (pm *Manager) InitProgress(ctx context.Context, taskID, peerID, clientID string) (err error)

InitProgress inits the correlation information between peers and pieces, etc.

func (*Manager) UpdateClientProgress

func (pm *Manager) UpdateClientProgress(ctx context.Context, taskID, srcCID, dstPID string, pieceNum, pieceStatus int) error

UpdateClientProgress updates the clientProgress and superProgress.

func (*Manager) UpdateProgress

func (pm *Manager) UpdateProgress(ctx context.Context, taskID, srcCID, srcPID, dstPID string, pieceNum, pieceStatus int) error

UpdateProgress updates the correlation information between peers and pieces. NOTE: What if the update failed?

Jump to

Keyboard shortcuts

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