ethmonitor

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: LGPL-3.0, MIT Imports: 13 Imported by: 1

README

ethmonitor

inspired by the work of the 0x team at github.com/0xProject/0x-mesh

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFatal                 = errors.New("ethmonitor: fatal error, stopping.")
	ErrReorg                 = errors.New("ethmonitor: block reorg")
	ErrUnexpectedParentHash  = errors.New("ethmonitor: unexpected parent hash")
	ErrUnexpectedBlockNumber = errors.New("ethmonitor: unexpected block number")
	ErrQueueFull             = errors.New("ethmonitor: publish queue is full")
	ErrMaxAttempts           = errors.New("ethmonitor: max attempts hit")
)
View Source
var DefaultOptions = Options{
	Logger:                   util.NewLogger(util.LogLevel_WARN),
	PollingInterval:          1000 * time.Millisecond,
	Timeout:                  60 * time.Second,
	StartBlockNumber:         nil,
	TrailNumBlocksBehindHead: 0,
	BlockRetentionLimit:      200,
	WithLogs:                 false,
	LogTopics:                []common.Hash{},
	DebugLogging:             false,
}

Functions

func IsBlockEq added in v1.7.0

func IsBlockEq(a, b *types.Block) bool

Types

type Block

type Block struct {
	*types.Block
	Event Event
	Logs  []types.Log
	OK    bool
}

type Blocks

type Blocks []*Block

func (Blocks) Copy added in v1.3.0

func (blocks Blocks) Copy() Blocks

func (Blocks) EventExists added in v1.3.0

func (blocks Blocks) EventExists(block *types.Block, event Event) bool

func (Blocks) FindBlock

func (blocks Blocks) FindBlock(hash common.Hash, optEvent ...Event) (*Block, bool)

func (Blocks) Head added in v1.7.0

func (b Blocks) Head() *Block

func (Blocks) IsOK added in v1.7.0

func (b Blocks) IsOK() bool

func (Blocks) LatestBlock

func (b Blocks) LatestBlock() *Block

func (Blocks) Reorg added in v1.7.0

func (b Blocks) Reorg() bool

func (Blocks) Tail added in v1.7.0

func (b Blocks) Tail() *Block

type Chain

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

func (*Chain) Blocks

func (c *Chain) Blocks() Blocks

func (*Chain) GetBlock

func (c *Chain) GetBlock(hash common.Hash) *Block

func (*Chain) GetBlockByNumber added in v1.3.2

func (c *Chain) GetBlockByNumber(blockNum uint64, event Event) *Block

func (*Chain) GetTransaction

func (c *Chain) GetTransaction(hash common.Hash) *types.Transaction

func (*Chain) Head

func (c *Chain) Head() *Block

func (*Chain) PrintAllBlocks

func (c *Chain) PrintAllBlocks()

func (*Chain) Tail added in v1.7.0

func (c *Chain) Tail() *Block

type Event added in v1.3.0

type Event uint32
const (
	Added Event = iota
	Removed
)

type Monitor

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

func NewMonitor

func NewMonitor(provider *ethrpc.Provider, opts ...Options) (*Monitor, error)

func (*Monitor) Chain

func (m *Monitor) Chain() *Chain

func (*Monitor) GetBlock

func (m *Monitor) GetBlock(hash common.Hash) *Block

GetBlock will search the retained blocks for the hash

func (*Monitor) GetTransaction

func (m *Monitor) GetTransaction(hash common.Hash) *types.Transaction

GetBlock will search within the retained blocks for the txn hash

func (*Monitor) IsRunning

func (m *Monitor) IsRunning() bool

func (*Monitor) LatestBlock

func (m *Monitor) LatestBlock() *Block

LatestBlock will return the head block of the retained chain

func (*Monitor) Options

func (m *Monitor) Options() Options

func (*Monitor) Provider added in v1.1.10

func (m *Monitor) Provider() *ethrpc.Provider

func (*Monitor) Run added in v1.6.1

func (m *Monitor) Run(ctx context.Context) error

func (*Monitor) Stop

func (m *Monitor) Stop()

func (*Monitor) Subscribe

func (m *Monitor) Subscribe() Subscription

type Options

type Options struct {
	// ..
	Logger util.Logger

	// ..
	PollingInterval time.Duration

	// ..
	Timeout time.Duration

	// ..
	StartBlockNumber *big.Int

	// ..
	TrailNumBlocksBehindHead int

	// ..
	BlockRetentionLimit int

	// ..
	WithLogs bool

	// ..
	LogTopics []common.Hash

	// ..
	DebugLogging bool
}

type Subscription

type Subscription interface {
	Blocks() <-chan Blocks
	Done() <-chan struct{}
	Unsubscribe()
}

Jump to

Keyboard shortcuts

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