sync

package
v0.0.0-...-84d53aa Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: GPL-3.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BaseSearch   = "sync_base_req"
	BlockRequest = "sync_block_req"
)

SyncService messages

View Source
const (
	SimultaneousRequest        = 1
	DefaultResponseTimeLimit   = 2 * time.Second
	DefaultNumberOfRetry       = 5
	DefaultActiveDownloadLimit = 10
)

Parameters related sync service

Variables

View Source
var (
	ErrContextDone         = errors.New("context is closed")
	ErrDownloadCtxDone     = errors.New("sync download context is done")
	ErrTimeout             = errors.New("timeout to wait response")
	ErrDifferentTargetHash = errors.New("target hash is different")
	ErrDownloadActivated   = errors.New("download is already activated")
	ErrFailedToConnect     = errors.New("failed to connect to peer")
	ErrLimitedRetry        = errors.New("retry is limited")
	ErrNotFound            = errors.New("not found")
	ErrWrongHeightBlock    = errors.New("peer send wrong block height")
)

Error types

Functions

This section is empty.

Types

type BlockManager

type BlockManager interface {
	Start()
	BlockHashByHeight(height uint64) ([]byte, error)
	BlockByHeight(height uint64) (*core.Block, error)
	BlockByHash(hash []byte) *core.Block
	LIB() *core.Block
	PushBlockDataSync(bd *core.BlockData, timeLimit time.Duration) error
	PushBlockDataSync2(ctx context.Context, bd *core.BlockData) error
}

BlockManager is interface of core.blockmanager.

type DownloadByHeightQuery

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

DownloadByHeightQuery is a query to download block

func (*DownloadByHeightQuery) Hash

func (q *DownloadByHeightQuery) Hash() []byte

Hash returns hash

func (*DownloadByHeightQuery) MessageType

func (*DownloadByHeightQuery) MessageType() string

MessageType returns message type

func (*DownloadByHeightQuery) ProtoBuf

func (q *DownloadByHeightQuery) ProtoBuf() proto.Message

ProtoBuf returns proto buffer

func (*DownloadByHeightQuery) SetID

func (q *DownloadByHeightQuery) SetID(id string)

SetID sets query id

type FindBaseQuery

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

FindBaseQuery is a query to find base block

func (*FindBaseQuery) Hash

func (q *FindBaseQuery) Hash() []byte

Hash returns hash

func (*FindBaseQuery) MessageType

func (*FindBaseQuery) MessageType() string

MessageType returns message type

func (*FindBaseQuery) ProtoBuf

func (q *FindBaseQuery) ProtoBuf() proto.Message

ProtoBuf returns protobuf

func (*FindBaseQuery) SetID

func (q *FindBaseQuery) SetID(id string)

SetID sets query id

type Service

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

Service is the service for sync service

func NewService

func NewService(cfg *medletpb.SyncConfig) *Service

NewService returns new syncService

func (*Service) Download

func (s *Service) Download(bd *core.BlockData) error

Download start sync download

func (*Service) IsDownloadActivated

func (s *Service) IsDownloadActivated() bool

IsDownloadActivated return status of activation

func (*Service) Setup

func (s *Service) Setup(netService net.Service, bm BlockManager)

Setup makes seeding and block manager on syncService

func (*Service) Start

func (s *Service) Start(ctx context.Context)

Start Sync Service

Directories

Path Synopsis
Package syncpb is a generated protocol buffer package.
Package syncpb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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