synchronizer

package
v3.0.0-rc2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Done hash state type
	Done string = "Done"
	// Wait hash state type
	Wait string = "Wait"
)
View Source
const (
	// Head hashList node
	Head string = "Head"
	// Tail hashList node
	Tail string = "Tail"
)
View Source
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

type FreePeerFunc = func(hash string, p interface{}) (missionCompleted bool)

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.

func (*SyncImpl) Start

func (sy *SyncImpl) Start() error

Start starts the synchronizer module.

func (*SyncImpl) Stop

func (sy *SyncImpl) Stop()

Stop stops the synchronizer module.

type Synchronizer

type Synchronizer interface {
	Start() error
	Stop()
	CheckSync() bool
	CheckGenBlock(hash []byte) bool
	CheckSyncProcess()
}

Synchronizer defines the functions of synchronizer module

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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