ethmonitor

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 12 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 (
	ErrUnexpectedParentHash  = fmt.Errorf("unexpected parent hash")
	ErrUnexpectedBlockNumber = fmt.Errorf("unexpected block number")
)
View Source
var DefaultOptions = Options{
	Logger:              log.New(os.Stdout, "", 0),
	PollingInterval:     1 * time.Second,
	PollingTimeout:      120 * time.Second,
	StartBlockNumber:    nil,
	BlockRetentionLimit: 20,
	WithLogs:            true,
	LogTopics:           []common.Hash{},
	DebugLogging:        false,
}

Functions

This section is empty.

Types

type Block

type Block struct {
	*types.Block
	Type BlockType
	Logs []types.Log
	// contains filtered or unexported fields
}

type BlockType

type BlockType uint32
const (
	Added BlockType = iota
	Removed
	Updated
)

type Blocks

type Blocks []*Block

func (Blocks) FindBlock

func (b Blocks) FindBlock(hash common.Hash) (*Block, bool)

func (Blocks) LatestBlock

func (b Blocks) LatestBlock() *Block

type Chain

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

func (*Chain) Blocks

func (c *Chain) Blocks() []*Block

func (*Chain) GetBlock

func (c *Chain) GetBlock(hash common.Hash) *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()

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) Start

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

func (*Monitor) Stop

func (m *Monitor) Stop() error

func (*Monitor) Subscribe

func (m *Monitor) Subscribe() Subscription

type Options

type Options struct {
	Logger              util.Logger
	PollingInterval     time.Duration
	PollingTimeout      time.Duration
	StartBlockNumber    *big.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