sync

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: LGPL-3.0 Imports: 21 Imported by: 2

Documentation

Overview

sync cp2fp contains the implementation of fractal sync checkpoint to fixpoint.

Package sync contains the implementation of fractal sync strategy. TODO: what will happen if malicious player exists

sync check contains the implementation of fractal fetch hashes.

Package sync contains the implementation of fractal sync strategy.

sync spiral contains the implementation of fractal sync complex mode.

Package sync contains the implementation of fractal sync strategy.

Package sync contains the implementation of fractal sync strategy.

Index

Constants

View Source
const (
	FastSyncModeBegin = iota
	FastSyncModeNone
	FastSyncModeEasy
	FastSyncModeComplex
	FastSyncModeEnd
)

Variables

View Source
var (
	ErrMainBlockCheckAndExecFailed = errors.New("main block check or exec failed")
)

Functions

func NewBlockCache

func NewBlockCache(clearCycleCount int, greedy uint8, remainedLen int) *blockCache

Types

type CP2FPSync

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

type CP2FPTask

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

type Cursor

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

use cursor for block process

func NewCursor

func NewCursor(hashElems protocol.HashElems, chain blockchain, packer packer.Packer, setHead bool, remainedLen int) *Cursor

func (*Cursor) Finish

func (c *Cursor) Finish()

func (*Cursor) IsFinished

func (c *Cursor) IsFinished() bool

func (*Cursor) IsRunning

func (c *Cursor) IsRunning() bool

func (*Cursor) ProcessBlock

func (c *Cursor) ProcessBlock(block *types.Block) error

func (*Cursor) Start

func (c *Cursor) Start()

type FastSyncMode

type FastSyncMode int

FastSyncMode is the mode for fast sync

func (FastSyncMode) String

func (m FastSyncMode) String() string

type FastSyncStatus

type FastSyncStatus int

FastSyncStatus is the child status for StatusFastSync

const (
	FastSyncStatusBegin FastSyncStatus = iota

	FastSyncStatusNone
	FastSyncStatusShortHashList

	// for complex mode
	FastSyncStatusLongHashList
	FastSyncStatusCheckMainChain

	// for fix point fetch
	FastSyncStatusFixPointPreBlocks
	FastSyncStatusFixPointPreStates
	FastSyncStatusFixPointPostBlocks

	FastSyncStatusEnd
)

func (FastSyncStatus) String

func (s FastSyncStatus) String() string

type PeerHashElemList

type PeerHashElemList struct {
	HashType protocol.SyncHashType
	Peer     *network.Peer
	HashList []*protocol.HashElem
}

type SyncStatus

type SyncStatus int

SyncStatus is the top status for sync process

const (
	SyncStatusBegin SyncStatus = iota
	SyncStatusInit
	SyncStatusFastSync
	SyncStatusNormal
	SyncStatusPeerSync
	SyncStatusEnd
)

func (SyncStatus) String

func (s SyncStatus) String() string

type Synchronizer

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

func NewSynchronizer

func NewSynchronizer(chain blockchain, miner miner, packer packer.Packer, removePeerCallback removePeerCallback, finishDependErr finishDepend, blockProcessCh chan *network.BlockWithVerifyFlag, conf *config.SyncConfig) *Synchronizer

func (*Synchronizer) AddPeer

func (s *Synchronizer) AddPeer(p *network.Peer)

func (*Synchronizer) DoPeerSync

func (s *Synchronizer) DoPeerSync(p *network.Peer)

func (*Synchronizer) GetConfig

func (s *Synchronizer) GetConfig() *config.SyncConfig

func (*Synchronizer) GetFastSyncMode

func (s *Synchronizer) GetFastSyncMode() FastSyncMode

func (*Synchronizer) GetFastSyncStatus

func (s *Synchronizer) GetFastSyncStatus() FastSyncStatus

func (*Synchronizer) GetSyncStatus

func (s *Synchronizer) GetSyncStatus() SyncStatus

func (*Synchronizer) HandleHashesRequest

func (s *Synchronizer) HandleHashesRequest(p *network.Peer, hashesReq protocol.SyncHashListReq)

func (*Synchronizer) HandleHashesResponse

func (s *Synchronizer) HandleHashesResponse(p *network.Peer, hashesRes protocol.SyncHashListRsp)

func (*Synchronizer) IsSyncStatusNormal

func (s *Synchronizer) IsSyncStatusNormal() bool

func (*Synchronizer) ProcessBlocksReq

func (s *Synchronizer) ProcessBlocksReq(peer *network.Peer, stage protocol.SyncStage, roundFrom uint64, roundTo uint64) error

func (*Synchronizer) ProcessBlocksRsp

func (s *Synchronizer) ProcessBlocksRsp(peer *network.Peer, stage protocol.SyncStage, blocks types.Blocks)

func (*Synchronizer) ProcessNodeData

func (s *Synchronizer) ProcessNodeData(p *network.Peer, data [][]byte)

func (*Synchronizer) ProcessSyncPostBlocksForStateReq

func (s *Synchronizer) ProcessSyncPostBlocksForStateReq(p *network.Peer, hashReq protocol.IntervalHashReq) error

func (*Synchronizer) ProcessSyncPostBlocksForStateRsp

func (s *Synchronizer) ProcessSyncPostBlocksForStateRsp(blocks types.Blocks)

func (*Synchronizer) ProcessSyncPreBlocksForStateReq

func (s *Synchronizer) ProcessSyncPreBlocksForStateReq(p *network.Peer, hash common.Hash) error

func (*Synchronizer) ProcessSyncPreBlocksForStateRsp

func (s *Synchronizer) ProcessSyncPreBlocksForStateRsp(blocks types.Blocks)

func (*Synchronizer) ProcessTxPackagesReq

func (s *Synchronizer) ProcessTxPackagesReq(peer *network.Peer, stage protocol.SyncStage, pkgHashes []common.Hash, bucket *ratelimit.Bucket, waitTime time.Duration)

func (*Synchronizer) ProcessTxPackagesRsp

func (s *Synchronizer) ProcessTxPackagesRsp(peer *network.Peer, stage protocol.SyncStage, pkgs []*types.TxPackage)

func (*Synchronizer) RemovePeer

func (s *Synchronizer) RemovePeer(p *network.Peer)

no need to unregister peers in downloader, they need to be unregistered where they are used

func (*Synchronizer) Start

func (s *Synchronizer) Start()

func (*Synchronizer) Stop

func (s *Synchronizer) Stop()

Jump to

Keyboard shortcuts

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