chain

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeadEventRevert indicates that the event signals a reversion of a tipset from the chain
	HeadEventRevert = "revert"

	// HeadEventRevert indicates that the event signals the application of a tipset to the chain
	HeadEventApply = "apply"

	// HeadEventRevert indicates that the event signals the current known head tipset
	HeadEventCurrent = "current"
)

Constants for HeadEvent types

Variables

View Source
var (
	ErrCacheEmpty       = errors.New("cache empty")
	ErrAddOutOfOrder    = errors.New("added tipset height lower than current head")
	ErrRevertOutOfOrder = errors.New("reverted tipset does not match current head")
	ErrEmptyRevert      = errors.New("reverted received on empty cache")
)

Functions

This section is empty.

Types

type GapFiller

type GapFiller struct {
	DB *storage.Database
	// contains filtered or unexported fields
}

func NewGapFiller

func NewGapFiller(node lens.API, db *storage.Database, name string, minHeight, maxHeight uint64, tasks []string) *GapFiller

func (*GapFiller) Done added in v0.8.6

func (g *GapFiller) Done() <-chan struct{}

func (*GapFiller) Run

func (g *GapFiller) Run(ctx context.Context) error

type GapIndexer

type GapIndexer struct {
	DB *storage.Database
	// contains filtered or unexported fields
}

func NewGapIndexer

func NewGapIndexer(node lens.API, db *storage.Database, name string, minHeight, maxHeight uint64, tasks []string) *GapIndexer

func (*GapIndexer) Done added in v0.8.6

func (g *GapIndexer) Done() <-chan struct{}

func (*GapIndexer) Find added in v0.9.0

func (*GapIndexer) Run

func (g *GapIndexer) Run(ctx context.Context) error

type HeadEvent

type HeadEvent struct {
	Type   string
	TipSet *types.TipSet
}

A HeadEvent is a notification of a change at the head of the chain

type HeadNotifier

type HeadNotifier interface {
	// HeadEvents returns a channel that receives head events. It may be closed
	// by the sender of the events, in which case Err will return a non-nil error
	// explaining why. HeadEvents may return nil if this implementation will never
	// notify any events.
	HeadEvents() <-chan *HeadEvent

	// Err returns the reason for the closing of the HeadEvents channel.
	Err() error
}

A HeadNotifier reports tipset events that occur at the head of the chain

type TaskHeight

type TaskHeight struct {
	Task   string
	Height uint64
	Status string
}

type TipSetCache

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

TipSetCache is a cache of recent tipsets that can keep track of reversions. Inspired by tipSetCache in Lotus chain/events package.

func NewTipSetCache

func NewTipSetCache(size int) *TipSetCache

func (*TipSetCache) Add

func (c *TipSetCache) Add(ts *types.TipSet) (*types.TipSet, error)

Add adds a new tipset which becomes the new head of the cache. If the buffer is full, the tail being evicted is also returned.

func (*TipSetCache) Confidence added in v0.8.2

func (c *TipSetCache) Confidence() int

Confidence returns the number of tipset that the cache must hold before tipsets are evicted on Add.

func (*TipSetCache) Head

func (c *TipSetCache) Head() (*types.TipSet, error)

Head returns the tipset at the head of the cache.

func (*TipSetCache) Height

func (c *TipSetCache) Height() abi.ChainEpoch

Height returns the height of the current head or zero if the cache is empty.

func (*TipSetCache) Len

func (c *TipSetCache) Len() int

Len returns the number of tipsets in the cache. This will never exceed the size of the cache.

func (*TipSetCache) Reset

func (c *TipSetCache) Reset()

Reset removes all tipsets from the cache

func (*TipSetCache) Revert

func (c *TipSetCache) Revert(ts *types.TipSet) error

Revert removes the head tipset

func (*TipSetCache) SetCurrent

func (c *TipSetCache) SetCurrent(ts *types.TipSet) error

SetCurrent replaces the current head

func (*TipSetCache) Size

func (c *TipSetCache) Size() int

Size returns the maximum number of tipsets that may be present in the cache.

func (*TipSetCache) Tail

func (c *TipSetCache) Tail() (*types.TipSet, error)

Tail returns the tipset at the tail of the cache.

func (*TipSetCache) TailHeight

func (c *TipSetCache) TailHeight() abi.ChainEpoch

TailHeight returns the height of the current tail or zero if the cache is empty.

func (*TipSetCache) Warm added in v0.8.2

func (c *TipSetCache) Warm(ctx context.Context, head *types.TipSet, getTipSetFn func(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error)) error

Warm fills the TipSetCache with confidence tipsets so that subsequent calls to Add return a tipset.

type TipSetObserver

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

func (*TipSetObserver) Apply added in v0.9.0

func (h *TipSetObserver) Apply(ctx context.Context, from, to *types.TipSet) error

func (*TipSetObserver) Cancel added in v0.9.0

func (h *TipSetObserver) Cancel(err error)

func (*TipSetObserver) Err added in v0.9.0

func (h *TipSetObserver) Err() error

func (*TipSetObserver) HeadEvents added in v0.9.0

func (h *TipSetObserver) HeadEvents() <-chan *HeadEvent

func (*TipSetObserver) Revert added in v0.9.0

func (h *TipSetObserver) Revert(ctx context.Context, from, to *types.TipSet) error

func (*TipSetObserver) SetCurrent added in v0.9.0

func (h *TipSetObserver) SetCurrent(ctx context.Context, ts *types.TipSet) error

type Walker

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

Walker is a job that indexes blocks by walking the chain history.

func NewWalker

func NewWalker(obs *indexer.Manager, node lens.API, name string, minHeight, maxHeight int64) *Walker

func (*Walker) Done added in v0.8.6

func (c *Walker) Done() <-chan struct{}

func (*Walker) Run

func (c *Walker) Run(ctx context.Context) error

Run starts walking the chain history and continues until the context is done or the start of the chain is reached.

func (*Walker) WalkChain

func (c *Walker) WalkChain(ctx context.Context, node lens.API, ts *types.TipSet) error

type Watcher

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

Watcher is a task that indexes blocks by following the chain head.

func NewWatcher

func NewWatcher(api WatcherAPI, indexer *indexer.Manager, name string, confidence int, poolSize int, bufferSize int) *Watcher

NewWatcher creates a new Watcher. confidence sets the number of tipsets that will be held in a cache awaiting possible reversion. Tipsets will be written to the database when they are evicted from the cache due to incoming later tipsets.

func (*Watcher) Done added in v0.8.6

func (c *Watcher) Done() <-chan struct{}

func (*Watcher) Run

func (c *Watcher) Run(ctx context.Context) error

Run starts following the chain head and blocks until the context is done or an error occurs.

type WatcherAPI added in v0.9.0

type WatcherAPI interface {
	Observe(obs events.TipSetObserver) *types.TipSet
	//Unregister(obs events.TipSetObserver) bool
	ChainGetTipSet(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error)
}

Directories

Path Synopsis
adt
builtin
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/account
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/cron
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/init
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/market
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/miner
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/multisig
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/paych
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/power
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/reward
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
builtin/verifreg
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
policy
Code generated by: `make actors-gen`.
Code generated by: `make actors-gen`.
Code generate by: `make tasks-gen`.
Code generate by: `make tasks-gen`.

Jump to

Keyboard shortcuts

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