types

package
v1.2.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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.

func (*Target) HasChild added in v0.9.4

func (target *Target) HasChild(t *Target) bool

HasChild is another is a child target of current. if the t' blocks in a subset of current target ,the t is a child of current target

func (*Target) IsNeighbor added in v0.9.7

func (target *Target) IsNeighbor(t *Target) bool

IsNeighbor the target t is neighbor or not the same height, the same weight, the same parent is neighbor target. the can merge

func (*Target) Key added in v0.9.1

func (target *Target) Key() string

Key return identity of target . key=weight+height+parent

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

Len 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. First, check whether the weight is received or not, and the message will record the minimum weight. If the weight is less than the current weight, it will exit automatically. Then, check whether the current target and the recorded target can be merged. If they can be merged, a new target containing more blocks will be generated. Try to replace a sub target in idle state. If it does not exist, the message will be displayed, Try to replace the target with the lowest weight and idle. If the above two situations do not exist, check whether the task exceeds the maximum number of saved tasks. If the number exceeds the maximum number, the current target will be abandoned. If there are any vacancies, the current target will be appended to the end. After each completion of this process, all targets will be reordered. First, they will be sorted according to the weight from small to large, and then they will be sorted according to the number of blocks in the group from small to large, Include as many blocks as possible.

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

History return sync history

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)

Remove remote a target after sync completed First remove target from live queue, add the target to history.

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

func (*TargetTracker) SubNewTarget added in v1.2.0

func (tq *TargetTracker) SubNewTarget(key string, cacheSize int) chan struct{}

func (*TargetTracker) UnsubNewTarget added in v1.2.0

func (tq *TargetTracker) UnsubNewTarget(key string)

Jump to

Keyboard shortcuts

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