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 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()
- 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 ¶ added in v0.9.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 v0.9.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 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 ¶ added in v0.8.2
func (finder *Finder) GetHashByNoRsp(rsp *message.GetHashByNoRsp)
type FinderResult ¶
type FinderResult struct {
// contains filtered or unexported fields
}
type GetAnchorsHookFn ¶ added in v0.9.0
type GetAnchorsHookFn func(stubSyncer *StubSyncer)
type GetSyncAncestorHookFn ¶ added in v0.9.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 v0.9.0
func (hf *HashFetcher) GetSeq() uint64
func (*HashFetcher) Start ¶
func (hf *HashFetcher) Start()
type HashRequest ¶
type HashRequest 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 v0.9.0
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 ¶ added in v0.9.0
func (syncer *Syncer) RecoverSyncerSelf()
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 ¶
type SyncerConfig ¶ added in v0.8.2
type SyncerConfig struct {
// contains filtered or unexported fields
}
type SyncerDebug ¶ added in v0.8.2
type TestResultFn ¶ added in v0.8.2
type TestResultFn func(stubSyncer *StubSyncer)
Click to show internal directories.
Click to hide internal directories.