watch

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: Apache-2.0, MIT Imports: 15 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 (
	WatcherDefaultBufferSize        = 5
	WatcherDefaultConfidence        = 1
	WatcherDefaultConcurrentWorkers = 1
	WatcherDefaultTasks             = tasktype.AllTableTasks
)

Functions

This section is empty.

Types

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 TipSetObserver

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

func (*TipSetObserver) Apply

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

func (*TipSetObserver) Cancel

func (h *TipSetObserver) Cancel(err error)

func (*TipSetObserver) Err

func (h *TipSetObserver) Err() error

func (*TipSetObserver) HeadEvents

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

func (*TipSetObserver) Revert

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

func (*TipSetObserver) SetCurrent

func (h *TipSetObserver) SetCurrent(ctx context.Context, 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.Indexer, name string, opts ...WatcherOpt) *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

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

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

type WatcherOpt

type WatcherOpt func(w *Watcher)

func WithBufferSize

func WithBufferSize(b int) WatcherOpt

func WithConcurrentWorkers

func WithConcurrentWorkers(p int) WatcherOpt

func WithConfidence

func WithConfidence(c int) WatcherOpt

func WithTasks

func WithTasks(tasks ...string) WatcherOpt

Jump to

Keyboard shortcuts

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