Documentation ¶
Index ¶
- Constants
- type Manager
- func (pm *Manager) DeletePeerIDByPieceNum(ctx context.Context, taskID string, pieceNum int, peerID string) error
- func (pm *Manager) DeletePeerStateByPeerID(ctx context.Context, peerID string) error
- func (pm *Manager) DeletePieceProgressByCID(ctx context.Context, taskID, clientID string) (err error)
- func (pm *Manager) GetBlackInfoByPeerID(ctx context.Context, peerID string) (dstPIDMap *cutil.SyncMap, err error)
- func (pm *Manager) GetPeerIDsByPieceNum(ctx context.Context, taskID string, pieceNum int) (peerIDs []string, err error)
- func (pm *Manager) GetPeerStateByPeerID(ctx context.Context, peerID string) (*mgr.PeerState, error)
- func (pm *Manager) GetPeersByTaskID(ctx context.Context, taskID string) (peersInfo []*types.PeerInfo, err error)
- func (pm *Manager) GetPieceProgressByCID(ctx context.Context, taskID, clientID, pieceStatus string) (pieceNums []int, err error)
- func (pm *Manager) InitProgress(ctx context.Context, taskID, peerID, clientID string) (err error)
- func (pm *Manager) UpdateClientProgress(ctx context.Context, taskID, srcCID, dstPID string, pieceNum, pieceStatus int) error
- func (pm *Manager) UpdateProgress(ctx context.Context, taskID, srcCID, srcPID, dstPID string, ...) error
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
InitProgress inits the correlation information between peers and pieces, etc.