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
- Variables
- func NewBlockCache(clearCycleCount int, greedy uint8, remainedLen int) *blockCache
- type CP2FPSync
- type CP2FPTask
- type Cursor
- type FastSyncMode
- type FastSyncStatus
- type PeerHashElemList
- type SyncStatus
- type Synchronizer
- func (s *Synchronizer) AddPeer(p *network.Peer)
- func (s *Synchronizer) DoPeerSync(p *network.Peer)
- func (s *Synchronizer) GetConfig() *config.SyncConfig
- func (s *Synchronizer) GetFastSyncMode() FastSyncMode
- func (s *Synchronizer) GetFastSyncStatus() FastSyncStatus
- func (s *Synchronizer) GetSyncStatus() SyncStatus
- func (s *Synchronizer) HandleHashesRequest(p *network.Peer, hashesReq protocol.SyncHashListReq)
- func (s *Synchronizer) HandleHashesResponse(p *network.Peer, hashesRes protocol.SyncHashListRsp)
- func (s *Synchronizer) IsSyncStatusNormal() bool
- func (s *Synchronizer) ProcessBlocksReq(peer *network.Peer, stage protocol.SyncStage, roundFrom uint64, roundTo uint64) error
- func (s *Synchronizer) ProcessBlocksRsp(peer *network.Peer, stage protocol.SyncStage, blocks types.Blocks)
- func (s *Synchronizer) ProcessNodeData(p *network.Peer, data [][]byte)
- func (s *Synchronizer) ProcessSyncPostBlocksForStateReq(p *network.Peer, hashReq protocol.IntervalHashReq) error
- func (s *Synchronizer) ProcessSyncPostBlocksForStateRsp(blocks types.Blocks)
- func (s *Synchronizer) ProcessSyncPreBlocksForStateReq(p *network.Peer, hash common.Hash) error
- func (s *Synchronizer) ProcessSyncPreBlocksForStateRsp(blocks types.Blocks)
- func (s *Synchronizer) ProcessTxPackagesReq(peer *network.Peer, stage protocol.SyncStage, pkgHashes []common.Hash, ...)
- func (s *Synchronizer) ProcessTxPackagesRsp(peer *network.Peer, stage protocol.SyncStage, pkgs []*types.TxPackage)
- func (s *Synchronizer) RemovePeer(p *network.Peer)
- func (s *Synchronizer) Start()
- func (s *Synchronizer) Stop()
Constants ¶
const ( FastSyncModeBegin = iota FastSyncModeNone FastSyncModeEasy FastSyncModeComplex FastSyncModeEnd )
Variables ¶
var (
ErrMainBlockCheckAndExecFailed = errors.New("main block check or exec failed")
)
Functions ¶
func NewBlockCache ¶
Types ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
use cursor for block process
func (*Cursor) IsFinished ¶
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 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 (*Synchronizer) ProcessBlocksRsp ¶
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 (*Synchronizer) ProcessSyncPreBlocksForStateRsp ¶
func (s *Synchronizer) ProcessSyncPreBlocksForStateRsp(blocks types.Blocks)
func (*Synchronizer) ProcessTxPackagesReq ¶
func (*Synchronizer) ProcessTxPackagesRsp ¶
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()