Documentation ¶
Index ¶
- Variables
- func RecoverSyncer(name string, seq uint64, compRequester component.IComponentRequester, ...)
- type BlockFetcher
- type BlockFetcherStat
- type BlockProcessor
- type ConnectTask
- type ErrSyncMsg
- type FetchTask
- type Finder
- type FinderResult
- type GetAnchorsHookFn
- type GetSyncAncestorHookFn
- type HashFetcher
- type HashRequest
- type HashSet
- type LogBlockHashesMarshaller
- type PeerSet
- type SortedTaskQueue
- type StubPeer
- type StubRequestResult
- type StubRequester
- func (compRequester *StubRequester) RequestTo(targetCompName string, message interface{})
- func (compRequester *StubRequester) RequestToFutureResult(targetName string, message interface{}, timeout time.Duration, tip string) (interface{}, error)
- func (compRequester *StubRequester) TellTo(targetName string, message interface{})
- type StubSyncer
- func (syncer *StubSyncer) AddBlock(msg *message.AddBlock, responseErr error)
- func (syncer *StubSyncer) GetAnchors(msg *message.GetAnchors)
- func (syncer *StubSyncer) GetBlockChunks(msg *message.GetBlockChunks)
- func (syncer *StubSyncer) GetHashByNo(msg *message.GetHashByNo)
- func (syncer *StubSyncer) GetHashes(msg *message.GetHashes, responseErr error)
- func (syncer *StubSyncer) GetPeers(msg *message.GetPeers)
- func (syncer *StubSyncer) GetSyncAncestor(msg *message.GetSyncAncestor)
- func (syncer *StubSyncer) SendGetSyncAncestorRsp(msg *message.GetSyncAncestor)
- type SyncPeer
- type Syncer
- func (syncer *Syncer) AfterStart()
- func (syncer *Syncer) BeforeStart()
- func (syncer *Syncer) BeforeStop()
- func (syncer *Syncer) GetSeq() uint64
- func (syncer *Syncer) IncSeq() uint64
- func (syncer *Syncer) Receive(context actor.Context)
- func (syncer *Syncer) RecoverSyncerSelf()
- func (syncer *Syncer) Reset(err error)
- func (syncer *Syncer) SetRequester(stubRequester component.IComponentRequester)
- func (syncer *Syncer) Statistics() *map[string]interface{}
- type SyncerConfig
- type SyncerDebug
- type TaskQueue
- type TestResultFn
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 ErrSyncMsg ¶
type ErrSyncMsg struct {
// contains filtered or unexported fields
}
func (*ErrSyncMsg) Error ¶
func (ec *ErrSyncMsg) Error() string
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
func (*Finder) GetHashByNoRsp ¶
func (finder *Finder) GetHashByNoRsp(rsp *message.GetHashByNoRsp)
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 LogBlockHashesMarshaller ¶
type LogBlockHashesMarshaller struct {
// contains filtered or unexported fields
}
func (LogBlockHashesMarshaller) MarshalZerologArray ¶
func (m LogBlockHashesMarshaller) MarshalZerologArray(a *zerolog.Array)
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 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) 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) RecoverSyncerSelf ¶
func (syncer *Syncer) RecoverSyncerSelf()
func (*Syncer) SetRequester ¶
func (syncer *Syncer) SetRequester(stubRequester component.IComponentRequester)
This api used for test to set stub IComponentRequester
func (*Syncer) Statistics ¶
type SyncerConfig ¶
type SyncerConfig struct {
// contains filtered or unexported fields
}
type SyncerDebug ¶
type TestResultFn ¶
type TestResultFn func(stubSyncer *StubSyncer)
Click to show internal directories.
Click to hide internal directories.