syncer

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 2, 2019 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DfltFetchTimeOut     = time.Second * 30
	DfltBlockFetchSize   = 100
	MaxPeerFailCount     = 3
	DfltBlockFetchTasks  = 5
	MaxBlockPendingTasks = 10
)
View Source
var (
	ErrAllPeerBad       = errors.New("BlockFetcher: error no avaliable peers")
	ErrQuitBlockFetcher = errors.New("BlockFetcher quit")
)
View Source
var (
	ErrFinderQuit               = errors.New("sync finder quit")
	ErrorGetSyncAncestorTimeout = errors.New("timeout for GetSyncAncestor")
	ErrFinderTimeout            = errors.New("Finder timeout")
	ErrAlreadySyncDone          = errors.New("Already sync done")
)
View Source
var (
	ErrQuitHashFetcher    = errors.New("Hashfetcher quit")
	ErrInvalidHashSet     = errors.New("Invalid hash set reply")
	ErrHashFetcherTimeout = errors.New("HashFetcher response timeout")
)
View Source
var (
	TestMaxBlockFetchSize = 2
	TestMaxHashReqSize    = uint64(3)
)
View Source
var (
	NameFinder         = "Finder"
	NameHashFetcher    = "HashFetcher"
	NameBlockFetcher   = "BlockFetcher"
	NameBlockProcessor = "BlockProcessor"
	SyncerCfg          = &SyncerConfig{
		maxHashReqSize:   DfltHashReqSize,
		maxBlockReqSize:  DfltBlockFetchSize,
		maxPendingConn:   MaxBlockPendingTasks,
		maxBlockReqTasks: DfltBlockFetchTasks,
		fetchTimeOut:     DfltFetchTimeOut,
		useFullScanOnly:  false}
)
View Source
var (
	ErrFinderInternal = errors.New("error finder internal")
	ErrSyncerPanic    = errors.New("syncer panic")
)
View Source
var (
	DfltHashReqSize = uint64(1000)
)
View Source
var (
	ErrHubFutureTimeOut = errors.New("stub compRequester request future timeout")
)

Functions

func RecoverSyncer added in v0.10.0

func RecoverSyncer(name string, seq uint64, compRequester component.IComponentRequester, finalize func())

Types

type BlockFetcher

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

func (*BlockFetcher) GetSeq added in v1.0.0

func (bf *BlockFetcher) GetSeq() uint64

func (*BlockFetcher) Start

func (bf *BlockFetcher) Start()

type BlockFetcherStat

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

type BlockProcessor

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

func NewBlockProcessor

func NewBlockProcessor(compRequester component.IComponentRequester, blockFetcher *BlockFetcher, ancestor *types.Block,
	targetNo types.BlockNo) *BlockProcessor

func (*BlockProcessor) AddBlockResponse

func (bproc *BlockProcessor) AddBlockResponse(msg *message.AddBlockRsp) error

func (*BlockProcessor) GetBlockChunkRsp

func (bproc *BlockProcessor) GetBlockChunkRsp(msg *message.GetBlockChunksRsp) error

func (*BlockProcessor) GetBlockChunkRspError

func (bproc *BlockProcessor) GetBlockChunkRspError(msg *message.GetBlockChunksRsp, err error) error

type ConnectTask

type ConnectTask struct {
	FromPeer peer.ID
	Blocks   []*types.Block
	// contains filtered or unexported fields
}

type ErrSyncMsg

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

func (*ErrSyncMsg) Error

func (ec *ErrSyncMsg) Error() string

type FetchTask

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

type Finder

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

func (*Finder) GetHashByNoRsp added in v0.8.2

func (finder *Finder) GetHashByNoRsp(rsp *message.GetHashByNoRsp)

func (*Finder) GetSeq added in v1.0.0

func (finder *Finder) GetSeq() uint64

type FinderResult

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

type GetAnchorsHookFn added in v0.9.9

type GetAnchorsHookFn func(stubSyncer *StubSyncer)

type GetSyncAncestorHookFn added in v1.0.0

type GetSyncAncestorHookFn func(stubSyncer *StubSyncer, msg *message.GetSyncAncestor)

type HashFetcher

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

func (*HashFetcher) GetHahsesRsp

func (hf *HashFetcher) GetHahsesRsp(msg *message.GetHashesRsp)

func (*HashFetcher) GetSeq added in v1.0.0

func (hf *HashFetcher) GetSeq() uint64

func (*HashFetcher) Start

func (hf *HashFetcher) Start()

type HashRequest

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

type HashSet

type HashSet struct {
	Count   int
	Hashes  []message.BlockHash
	StartNo types.BlockNo
}

type PeerSet

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

type SortedTaskQueue added in v0.8.2

type SortedTaskQueue struct {
	TaskQueue
}

func (*SortedTaskQueue) Push added in v0.8.2

func (squeue *SortedTaskQueue) Push(task *FetchTask)

type StubPeer

type StubPeer struct {
	HookGetBlockChunkRsp func(msgReq *message.GetBlockChunks)
	// contains filtered or unexported fields
}

func NewStubPeer

func NewStubPeer(idx int, lastNo uint64, blockChain *chain.StubBlockChain) *StubPeer

type StubRequestResult added in v0.8.2

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

func (*StubRequestResult) Result added in v0.8.2

func (stubResult *StubRequestResult) Result() (interface{}, error)

type StubRequester added in v0.8.2

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

func NewStubRequester added in v0.8.2

func NewStubRequester() *StubRequester

func (*StubRequester) RequestTo added in v0.8.2

func (compRequester *StubRequester) RequestTo(targetCompName string, message interface{})

func (*StubRequester) RequestToFutureResult added in v0.8.2

func (compRequester *StubRequester) RequestToFutureResult(targetName string, message interface{}, timeout time.Duration, tip string) (interface{}, error)

handle requestFuture requset this api must not use parallel. TODO use lock

func (*StubRequester) TellTo added in v0.8.2

func (compRequester *StubRequester) TellTo(targetName string, message interface{})

type StubSyncer

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

func NewTestSyncer added in v0.8.2

func NewTestSyncer(t *testing.T, localChain *chain.StubBlockChain, remoteChain *chain.StubBlockChain, peers []*StubPeer, cfg *SyncerConfig) *StubSyncer

func (*StubSyncer) AddBlock

func (syncer *StubSyncer) AddBlock(msg *message.AddBlock, responseErr error)

ChainService

func (*StubSyncer) GetAnchors added in v0.8.2

func (syncer *StubSyncer) GetAnchors(msg *message.GetAnchors)

reply to requestFuture()

func (*StubSyncer) GetBlockChunks

func (syncer *StubSyncer) GetBlockChunks(msg *message.GetBlockChunks)

func (*StubSyncer) GetHashByNo added in v0.8.2

func (syncer *StubSyncer) GetHashByNo(msg *message.GetHashByNo)

func (*StubSyncer) GetHashes added in v0.8.2

func (syncer *StubSyncer) GetHashes(msg *message.GetHashes, responseErr error)

func (*StubSyncer) GetPeers added in v0.8.2

func (syncer *StubSyncer) GetPeers(msg *message.GetPeers)

func (*StubSyncer) GetSyncAncestor added in v0.8.2

func (syncer *StubSyncer) GetSyncAncestor(msg *message.GetSyncAncestor)

func (*StubSyncer) SendGetSyncAncestorRsp added in v1.0.0

func (syncer *StubSyncer) SendGetSyncAncestorRsp(msg *message.GetSyncAncestor)

type SyncPeer

type SyncPeer struct {
	No      int
	ID      peer.ID
	FailCnt int
	IsErr   bool
}

type Syncer

type Syncer struct {
	*component.BaseComponent

	Seq uint64
	// contains filtered or unexported fields
}

func NewSyncer

func NewSyncer(cfg *cfg.Config, chain types.ChainAccessor, syncerCfg *SyncerConfig) *Syncer

func (*Syncer) AfterStart

func (syncer *Syncer) AfterStart()

AfterStart ... do nothing

func (*Syncer) BeforeStart

func (syncer *Syncer) BeforeStart()

BeforeStart initialize chain database and generate empty genesis block if necessary

func (*Syncer) BeforeStop

func (syncer *Syncer) BeforeStop()

func (*Syncer) GetSeq added in v1.0.0

func (syncer *Syncer) GetSeq() uint64

func (*Syncer) IncSeq added in v1.0.0

func (syncer *Syncer) IncSeq() uint64

func (*Syncer) Receive

func (syncer *Syncer) Receive(context actor.Context)

Receive actor message

func (*Syncer) RecoverSyncerSelf added in v0.10.0

func (syncer *Syncer) RecoverSyncerSelf()

func (*Syncer) Reset

func (syncer *Syncer) Reset()

func (*Syncer) SetRequester added in v0.8.2

func (syncer *Syncer) SetRequester(stubRequester component.IComponentRequester)

This api used for test to set stub IComponentRequester

func (*Syncer) Statistics

func (syncer *Syncer) Statistics() *map[string]interface{}

type SyncerConfig added in v0.8.2

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

type SyncerDebug added in v0.8.2

type SyncerDebug struct {
	BfWaitTime time.Duration
	// contains filtered or unexported fields
}

type TaskQueue

type TaskQueue struct {
	list.List
}

func (*TaskQueue) Peek added in v0.8.2

func (tq *TaskQueue) Peek() *FetchTask

func (*TaskQueue) Pop

func (tq *TaskQueue) Pop() *FetchTask

type TestResultFn added in v0.8.2

type TestResultFn func(stubSyncer *StubSyncer)

Jump to

Keyboard shortcuts

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