events

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: Apache-2.0, MIT Imports: 13 Imported by: 14

Documentation

Index

Constants

View Source
const NoTimeout = math.MaxUint64

Variables

This section is empty.

Functions

This section is empty.

Types

type CalledHandler

type CalledHandler func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (more bool, err error)

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

type CheckFunc

type CheckFunc func(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 CalledHandler (RevertHandler

may still be called)

type Events

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

func NewEvents

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

func (*Events) Called

func (e *Events) Called(check CheckFunc, hnd CalledHandler, rev RevertHandler, confidence int, timeout uint64, mf MatchFunc) error

Called registers a callbacks which are triggered when a specified method is

called on an actor, or a timeout is reached.
  • `CheckFunc` callback is invoked immediately with a recent tipset, it returns two booleans - `done`, and `more`.

  • `done` should be true when some on-chain action we are waiting for has happened. When `done` is set to true, timeout trigger is disabled.

  • `more` should be false when we don't want to receive new notifications through CalledHandler. Note that notifications may still be delivered to RevertHandler

  • `CalledHandler` is called when the specified event was observed on-chain, and a confidence threshold was reached, or the specified `timeout` height was reached with no events observed. When this callback is invoked on a timeout, `msg` is set to nil. This callback returns a boolean specifying whether further notifications should be sent, like `more` return param from `CheckFunc` above.
  • `RevertHandler` is called after apply handler, when we drop the tipset containing the message. The tipset passed as the argument is the tipset that is being dropped. Note that the message dropped may be re-applied in a different tipset in small amount of time.

func (*Events) CalledMsg

func (e *Events) CalledMsg(ctx context.Context, hnd CalledHandler, rev RevertHandler, confidence int, timeout uint64, msg store.ChainMsg) error

func (*Events) ChainAt

func (e *Events) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h uint64) 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, or above, if lower tipsets were null

func (*Events) CheckMsg

func (e *Events) CheckMsg(ctx context.Context, smsg store.ChainMsg, hnd CalledHandler) CheckFunc

func (*Events) MatchMsg

func (e *Events) MatchMsg(inmsg *types.Message) MatchFunc

type HeightHandler

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

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

type MatchFunc

type MatchFunc func(msg *types.Message) (bool, error)

type RevertHandler

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

Jump to

Keyboard shortcuts

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