broadcaster

package
v0.0.0-...-21d01d2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockNumberMod

func BlockNumberMod(n uint64) func(number uint64) bool

BlockNumberMod returns true if the block number % n is 0

func EachBlockNumber

func EachBlockNumber() func(number uint64) bool

EachBlockNumber returns true

Types

type BlockOptions

type BlockOptions struct {
	// Number returns true if the block with the given number should be handled
	Number func(number uint64) bool
}

BlockOptions contains options to filter blocks

type Broadcaster

type Broadcaster interface {
	// RegisterEventHandler registers the given handler for specific events based on the given filters.
	RegisterEventHandler(id string, chainID uint64, handler HandleEventFunc, opts EventOptions) (func(), error)

	// RegisterBlockHandler registers the given handler for blocks based on the given filters.
	RegisterBlockHandler(id string, chainID uint64, handler HandleBlockFunc, opts BlockOptions) (func(), error)

	// Start starts broadcasting on-chain data to subscribers
	Start(ctx context.Context) error

	// Stop stops broadcasting
	Stop() error
}

Broadcaster represents a behavior of events broadcaster.

func NewMultiChain

func NewMultiChain(broadcasters map[uint64]Broadcaster) Broadcaster

NewMultiChain is the constructor of multiChainBroadcaster

func NewSingleChain

func NewSingleChain(ctx context.Context, logger logrus.FieldLogger, provider onchain.Provider, opts Options) (Broadcaster, error)

NewSingleChain is the constructor of singleChainBroadcaster

type Client

type Client interface {
	ethereum.LogFilterer
	ethereum.ChainReader
}

Client represents the behavior of the on-chain data provider

type EventOptions

type EventOptions struct {
	// Contracts contains contract addresses to listen events from.
	Contracts []common.Address

	// Event types to receive, with value filter for each field in the event
	// No filter or an empty filter for a given field position mean: all values allowed
	// the key should be a result of AbigenLog.Topic() call
	// topic => topicValueFilters
	LogsWithTopics map[common.Hash][][]common.Hash
}

EventOptions contains options to filter events

type HandleBlockFunc

type HandleBlockFunc func(ctx context.Context, header types.Header)

HandleBlockFunc is the signature of a function to handle heads

type HandleEventFunc

type HandleEventFunc func(ctx context.Context, event types.Log)

HandleEventFunc is the signature of a function to handle events

type Options

type Options struct {
	ChainID       uint64
	FinalityDepth uint64
	ForceBlock    uint64
}

Options contains options to create a broadcaster

Jump to

Keyboard shortcuts

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