Documentation ¶
Index ¶
- Constants
- type DownloadController
- type DownloadControllerImpl
- func (dc *DownloadControllerImpl) CreateMission(hash string, p interface{}, peerID p2p.PeerID)
- func (dc *DownloadControllerImpl) DownloadLoop(mFunc MissionFunc)
- func (dc *DownloadControllerImpl) FreePeerLoop(fpFunc FreePeerFunc)
- func (dc *DownloadControllerImpl) ReStart()
- func (dc *DownloadControllerImpl) Start()
- func (dc *DownloadControllerImpl) Stop()
- type FreePeerFunc
- type MissionFunc
- type SyncImpl
- type Synchronizer
Constants ¶
const ( // Done hash state type Done string = "Done" // Wait hash state type Wait string = "Wait" )
const ( // Head hashList node Head string = "Head" // Tail hashList node Tail string = "Tail" )
const ( // Free peer state type Free string = "Free" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DownloadController ¶
type DownloadController interface { CreateMission(hash string, p interface{}, peerID p2p.PeerID) Start() Stop() ReStart() DownloadLoop(mFunc MissionFunc) FreePeerLoop(fpFunc FreePeerFunc) }
DownloadController defines the functions of download controller.
type DownloadControllerImpl ¶
type DownloadControllerImpl struct {
// contains filtered or unexported fields
}
DownloadControllerImpl is the implementation of DownloadController.
func NewDownloadController ¶
func NewDownloadController(fpf FreePeerFunc, mf MissionFunc) (*DownloadControllerImpl, error)
NewDownloadController returns a DownloadController instance.
func (*DownloadControllerImpl) CreateMission ¶
func (dc *DownloadControllerImpl) CreateMission(hash string, p interface{}, peerID p2p.PeerID)
CreateMission adds a mission.
func (*DownloadControllerImpl) DownloadLoop ¶ added in v1.1.0
func (dc *DownloadControllerImpl) DownloadLoop(mFunc MissionFunc)
DownloadLoop is the Loop to download the mission.
func (*DownloadControllerImpl) FreePeerLoop ¶ added in v1.1.0
func (dc *DownloadControllerImpl) FreePeerLoop(fpFunc FreePeerFunc)
FreePeerLoop is the Loop to free the peer.
func (*DownloadControllerImpl) ReStart ¶ added in v1.1.0
func (dc *DownloadControllerImpl) ReStart()
ReStart restarts data.
func (*DownloadControllerImpl) Start ¶
func (dc *DownloadControllerImpl) Start()
Start starts the DownloadController.
func (*DownloadControllerImpl) Stop ¶
func (dc *DownloadControllerImpl) Stop()
Stop stops the DownloadController.
type FreePeerFunc ¶ added in v1.1.0
FreePeerFunc checks if the mission is completed.
type MissionFunc ¶ added in v1.1.0
type MissionFunc = func(hash string, p interface{}, peerID interface{}) (missionAccept bool, missionCompleted bool)
MissionFunc checks if the mission is completed or tries to do the mission.
type SyncImpl ¶
type SyncImpl struct {
// contains filtered or unexported fields
}
SyncImpl is the implementation of Synchronizer.
func NewSynchronizer ¶
func NewSynchronizer(basevariable global.BaseVariable, blkcache blockcache.BlockCache, p2pserv p2p.Service) (*SyncImpl, error)
NewSynchronizer returns a SyncImpl instance.
func (*SyncImpl) CheckSyncProcess ¶
func (sy *SyncImpl) CheckSyncProcess()
CheckSyncProcess checks if the end of sync.