Documentation ¶
Index ¶
Constants ¶
const ( StageIdle = SyncStateStage(iota) StateInSyncing StageSyncComplete StageSyncErrored )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadTipSetCache ¶
type BadTipSetCache struct {
// contains filtered or unexported fields
}
BadTipSetCache keeps track of bad tipsets that the syncer should not try to download. Readers and writers grab a lock. The purpose of this cache is to prevent a node from having to repeatedly invalidate a block (and its children) in the event that the tipset does not conform to the rules of consensus. Note that the cache is only in-memory, so it is reset whenever the node is restarted. TODO: this needs to be limited.
func NewBadTipSetCache ¶
func NewBadTipSetCache() *BadTipSetCache
func (*BadTipSetCache) Add ¶
func (cache *BadTipSetCache) Add(tsKey string)
Add adds a single tipset key to the BadTipSetCache.
func (*BadTipSetCache) AddChain ¶
func (cache *BadTipSetCache) AddChain(chain []*types.TipSet)
AddChain adds the chain of tipsets to the BadTipSetCache. For now it just does the simplest thing and adds all blocks of the chain to the cache. TODO: might want to cache a random subset once cache size is limited.
func (*BadTipSetCache) Has ¶
func (cache *BadTipSetCache) Has(tsKey string) bool
Has checks for membership in the BadTipSetCache.
type SyncStateStage ¶
type SyncStateStage int
just compatible code lotus
func (SyncStateStage) String ¶
func (v SyncStateStage) String() string
type Target ¶
type Target struct { State SyncStateStage Base *types.TipSet Current *types.TipSet Start time.Time End time.Time Err error types.ChainInfo }
Target tracks a logical request of the syncing subsystem to run a syncing job against given inputs.
type TargetBuckets ¶
type TargetBuckets []*Target
TargetBuckets orders targets by a policy.
The current simple policy is to order syncing requests by claimed chain height.
`TargetBuckets` can panic so it shouldn't be used unwrapped
func (TargetBuckets) Len ¶
func (rq TargetBuckets) Len() int
Heavily inspired by https://golang.org/pkg/container/heap/
func (TargetBuckets) Less ¶
func (rq TargetBuckets) Less(i, j int) bool
func (*TargetBuckets) Pop ¶
func (rq *TargetBuckets) Pop() interface{}
func (TargetBuckets) Swap ¶
func (rq TargetBuckets) Swap(i, j int)
type TargetTracker ¶
type TargetTracker struct {
// contains filtered or unexported fields
}
TargetTracker orders dispatcher syncRequests by the underlying `TargetBuckets`'s prioritization policy.
It also filters the `TargetBuckets` so that it always contains targets with unique chain heads.
It wraps the `TargetBuckets` to prevent panics during normal operation.
func NewTargetTracker ¶
func NewTargetTracker(size int) *TargetTracker
NewTargetTracker returns a new target queue.
func (*TargetTracker) Add ¶
func (tq *TargetTracker) Add(t *Target) bool
Add adds a sync target to the target queue.
func (*TargetTracker) Buckets ¶
func (tq *TargetTracker) Buckets() TargetBuckets
Buckets returns the number of targets in the queue.
func (*TargetTracker) History ¶
func (tq *TargetTracker) History() []*Target
func (*TargetTracker) Len ¶
func (tq *TargetTracker) Len() int
Len returns the number of targets in the queue.
func (*TargetTracker) Remove ¶
func (tq *TargetTracker) Remove(t *Target)
func (*TargetTracker) Select ¶
func (tq *TargetTracker) Select() (*Target, bool)
Pop removes and returns the highest priority syncing target. If there is nothing in the queue the second argument returns false