syncer

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 23 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

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

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 types.PeerID
	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

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

func (*Finder) GetSeq

func (finder *Finder) GetSeq() uint64

type FinderResult

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

type GetAnchorsHookFn

type GetAnchorsHookFn func(stubSyncer *StubSyncer)

type GetSyncAncestorHookFn

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

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 LogBlockHashesMarshaller

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

func (LogBlockHashesMarshaller) MarshalZerologArray

func (m LogBlockHashesMarshaller) MarshalZerologArray(a *zerolog.Array)

type PeerSet

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

type SortedTaskQueue

type SortedTaskQueue struct {
	TaskQueue
}

func (*SortedTaskQueue) Push

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

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

func (*StubRequestResult) Result

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

type StubRequester

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

func NewStubRequester

func NewStubRequester() *StubRequester

func (*StubRequester) RequestTo

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

func (*StubRequester) RequestToFutureResult

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

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

type StubSyncer

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

func NewTestSyncer

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

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

reply to requestFuture()

func (*StubSyncer) GetBlockChunks

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

func (*StubSyncer) GetHashByNo

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

func (*StubSyncer) GetHashes

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

func (*StubSyncer) GetPeers

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

func (*StubSyncer) GetSyncAncestor

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

func (*StubSyncer) SendGetSyncAncestorRsp

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

type SyncPeer

type SyncPeer struct {
	No      int
	ID      types.PeerID
	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

func (syncer *Syncer) GetSeq() uint64

func (*Syncer) IncSeq

func (syncer *Syncer) IncSeq() uint64

func (*Syncer) Receive

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

Receive actor message

func (*Syncer) RecoverSyncerSelf

func (syncer *Syncer) RecoverSyncerSelf()

func (*Syncer) Reset

func (syncer *Syncer) Reset(err error)

func (*Syncer) SetRequester

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

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

type SyncerDebug

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

type TaskQueue

type TaskQueue struct {
	list.List
}

func (*TaskQueue) Peek

func (tq *TaskQueue) Peek() *FetchTask

func (*TaskQueue) Pop

func (tq *TaskQueue) Pop() *FetchTask

type TestResultFn

type TestResultFn func(stubSyncer *StubSyncer)

Jump to

Keyboard shortcuts

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