events

package
v1.2.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: Apache-2.0, MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const NoHeight = abi.ChainEpoch(-1)
View Source
const NoTimeout = math.MaxInt64

Variables

View Source
var ObserveDuration = time.Second * 45

Functions

This section is empty.

Types

type CheckFunc

type CheckFunc func(ctx context.Context, ts *types.TipSet) (done bool, more bool, err error)

CheckFunc is used for atomicity guarantees. If the condition the callbacks wait for has already happened in tipset `ts`

If `done` is true, timeout won't be triggered If `more` is false, no messages will be sent to EventHandler (RevertHandler

may still be called)

type EventHandler

type EventHandler func(ctx context.Context, data eventData, prevTs, ts *types.TipSet, curH abi.ChainEpoch) (more bool, err error)

EventHandler arguments: `prevTs` is the previous tipset, eg the "from" tipset for a state change. `ts` is the event tipset, eg the tipset in which the `msg` is included. `curH`-`ts.Height` = `confidence`

type Events

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

func NewEvents

func NewEvents(ctx context.Context, api IEvent) (*Events, error)

func NewEventsWithConfidence added in v1.1.0

func NewEventsWithConfidence(ctx context.Context, api IEvent, gcConfidence abi.ChainEpoch) (*Events, error)

func (Events) ChainAt

func (e Events) ChainAt(ctx context.Context, hnd HeightHandler, rev RevertHandler, confidence int, h abi.ChainEpoch) error

ChainAt invokes the specified `HeightHandler` when the chain reaches the specified height+confidence threshold. If the chain is rolled-back under the specified height, `RevertHandler` will be called.

ts passed to handlers is the tipset at the specified epoch, or above if lower tipsets were null.

The context governs cancellations of this call, it won't cancel the event handler.

func (Events) Observe added in v1.1.0

func (o Events) Observe(obs TipSetObserver) *types.TipSet

Observe registers the observer, and returns the current tipset. The observer is guaranteed to observe events starting at this tipset.

Returns nil if the observer hasn't started yet (but still registers).

type HeightHandler

type HeightHandler func(ctx context.Context, ts *types.TipSet, curH abi.ChainEpoch) error

HeightHandler `curH`-`ts.Height` = `confidence`

type IEvent

type IEvent interface {
	ChainNotify(context.Context) (<-chan []*types.HeadChange, error)
	ChainGetBlockMessages(context.Context, cid.Cid) (*types.BlockMessages, error)
	ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
	ChainGetTipSetAfterHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
	ChainHead(context.Context) (*types.TipSet, error)
	StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*types.MsgLookup, error)
	ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
	ChainGetPath(ctx context.Context, from, to types.TipSetKey) ([]*types.HeadChange, error)

	StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) // optional / for CalledMsg
}

type MsgHandler

type MsgHandler func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (more bool, err error)

MsgHandler arguments: `ts` is the tipset, in which the `msg` is included. `curH`-`ts.Height` = `confidence`

type MsgMatchFunc

type MsgMatchFunc func(msg *types.Message) (matched bool, err error)

type RevertHandler

type RevertHandler func(ctx context.Context, ts *types.TipSet) error

HeightHandler `curH`-`ts.Height` = `confidence`

type StateChange

type StateChange interface{}

StateChange represents a change in state

type StateChangeHandler

type StateChangeHandler func(oldTs, newTs *types.TipSet, states StateChange, curH abi.ChainEpoch) (more bool, err error)

StateChangeHandler arguments: `oldTs` is the state "from" tipset `newTs` is the state "to" tipset `states` is the change in state `curH`-`ts.Height` = `confidence`

type StateMatchFunc

type StateMatchFunc func(oldTs, newTs *types.TipSet) (bool, StateChange, error)

type TipSetObserver added in v1.1.0

type TipSetObserver interface {
	Apply(ctx context.Context, from, to *types.TipSet) error
	Revert(ctx context.Context, from, to *types.TipSet) error
}

A TipSetObserver receives notifications of tipsets

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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